Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Exact Difference and Usage between .toString / String.valueOf() / (String)

800481Apr 27 2010 — edited Apr 27 2010
Hi

What are the differences in .toString / String.valueOf() / (String) ?

I have tried the following :
String a = "a";
	    Object o = "o";
	    int i = 1;
	    
	    System.out.println("String Value of " + String.valueOf(i));
	    System.out.println("(String) " + (String)o);
	    System.out.println(".toString() " + i.toString()); // does not work
	    System.out.println(".toString() " + String(i)); // does not work
Thanks in Advance !!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 25 2010
Added on Apr 27 2010
4 comments
1,522 views