difference between toString() and type casting a n Object to String

D

Danno

narsing said:
what is the difference between toString() and type casting a n Object
to String

Try it. Three lines is all it takes:

Integer mynum = new Integer(4);
System.out.println(mynum.toString());
System.out.println((String) mynum);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top