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)
Boolean.valueOf("True") returns true
sudipto shekhar
Ranch Hand
Posts: 826
I like...
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
In this code:
public class MyTest{ public static void main(String a[]){ System.out.println(testBox("True")); } public static Boolean testBox(String a){ return Boolean.valueOf(a); } }
the output is true. Isn't
Java
case sensitive?
What is happening here? Can anyone explain me?
Regards, Sud.
SCJP 5
ScjpFAQ
JLS
Balu Sadhasivam
Ranch Hand
Posts: 874
I like...
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Sudipto,
Here the
String
argument is validated with ignoring case . Look at the API , Its the default behaviour of
Boolean
Class as defined.
Abhi vijay
Ranch Hand
Posts: 509
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Boolean.valueOf("TruE"); // prints true. Boolean.valueOf(true);// prints true Boolean.valueOf(TruE);// Compiler Error.
In the first line you are passing a string value( note the double quotes). In this case it will ignore the case, since its a String.
You can refer to the JAVA API for more information.
Don't count your weasels before they've popped. And now for a mulberry bush related tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
why null pointer exception?
try this program
autoboxing
Boolean Wrappers?
More...