Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within OCPJP
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Programmer Certification (OCPJP)
char weirdness
M Mistroni
Ranch Hand
Posts: 66
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
hello all,
i tried following code in my
test
class
public static void main(
String
[] args) {
char c = '1';
int i = 0;
System.err.println(c + x );
}
result was 49..
could anyone explain me how that result gets outputted?
how to do conversion from char to int?
regards
marco
sky su
Greenhorn
Posts: 6
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
hi!!
char c = '1';
//int i = 0;
System.err.println(c); // will get 1
System.err.println((int)c);// will get 49
you konw the char in the println cast to int if you "i+c"(cast to int ) ,
when you only print c and not put anything you will get char!!
char c=(char)49;
System.out.println(c);// you will get 1
just like that!!you can try again! I wish that can help you !
He was giving me directions and I was powerless to resist. I cannot resist this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Character manipulation questions?
char and int
Marcus Green tutorial question
Convert string to integer without any API ?
Java in general
More...