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

android - net_scheduler holding wakelock -

sql - MySQL : Getting Entries from a many-to-many table -

java - Retrieving data from database using jsp (Hibernate + Spring + Maven) -