0
Class Output { Public static void main ( String args[]) { String str= "true false true"; boolean x= Boolean.valueOf(str); System.out.print(x); } }
What is the output of this program..?
5 Respostas
+ 5
false - because str doesn't contain a boolean value.
It will always output false, except for str="true";
+ 5
Ok ^^
This is a typecast from String to Boolean.
The Boolean to which was casted is true if the string is not null and is equal to the string "true" (ignoring case, so e.g "TRUE" or "tRue" is also true). Every other value stored to the string will be a Boolean representing false value after typecast.
+ 1
Okay..thank you for your time..
0
Can u explain little bit more..?
0
boolean and strings are two different types of variables. the program you gave as an example makes as much sence as "what does the number red smell like?"