is the value of java class object same as class name? -


hi beginner in java programming , having trouble understanding value of object be. debugging following program , while looking under variables tab in eclipse saw variable name ex , value exception. did not understand if instance of class has value same class name. can please help.

public void abc(int i)throws exception{     i++;     throw new exception("exception"); } public static void main(string [] args){     try{         test t = new test();         t.abc(5);     }catch(exception ex){         system.out.println(ex.tostring());     } } 

the value of exception whatever pass constructor:

throw new exception("exception"); 

as pass string "exception", see same ex value later.

in general better way print exception use printstacktrace method gives more details why happened:

 ex.printstacktrace(); 

Comments

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -