aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes String s = Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "String s = "" + (int)c;" Watch "String s = "" + (int)c;" New topic
Author

String s = "" + (int)c;

Karin Paola Illuminate
Ranch Hand

Joined: Oct 18, 2002
Posts: 109

How could I know that "" + c and "" + (int)c are not the same. I mean, how do I know that (int)c will return 97, and not, for example, 96 or 98? Should I know the exact integer, or should I only know that there is a difference for the exam?


I not only use all the brains that I have, but all that I can borrow. [Laurence J. Peter]
Leandro Oliveira
Ranch Hand

Joined: Nov 07, 2002
Posts: 298
For the exam, it's not required to know that (int)c would return 97, but you should know that it would return a number and ""+c would return "c". That is what the exam requires you to know!!
Leandro Oliveira
Ranch Hand

Joined: Nov 07, 2002
Posts: 298
ooops!!! forgive me... ""+c would return "a"
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: String s = "" + (int)c;
 
Similar Threads
Wrappers
narrowing
String Replacement problem
storing user defined variables in an array
Conversion of String to binary ?