This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
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 REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "String s = "" + (int)c;" Watch "String s = "" + (int)c;" New topic

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:
subject: String s = "" + (int)c;
It's not a secret anymore!