This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes convert Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "convert " Watch "convert " New topic
Author

convert

shirsa ray chaudhuri
Greenhorn

Joined: Apr 08, 2008
Posts: 10
int i=(int)c;

where char c='a';

is it write
Ravinder Partap
Greenhorn

Joined: Feb 03, 2008
Posts: 8
this is fine, but you could avoid the explicit casting as its done implecitly while widening 16 bit char to 32 bit int primitive.
int i= (int)c;
is equal to :
int i = c;
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: convert
 
Similar Threads
int c=1; c=c++; // c is then 1 not 2 !
Comparable again
int []c[] = new int [4][6]; is it a correct syntax ?
Get Ascii value for a character
Get Unicode of a character