Java by API/java.lang/Boolean — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Текущая версия на 14:40, 31 мая 2010
Содержание
Boolean: boolean booleanValue() (Returns the value of this Boolean object as a boolean primitive)
public class Main {
public static void main(String[] args) {
Boolean b1 = new Boolean(false);
Boolean b2 = new Boolean("true");
System.out.println(b1.booleanValue());
System.out.println(b2.booleanValue());
}
}
Boolean: parseBoolean(String s)
public class Main {
public static void main(String[] args) {
String strBoolean = "true";
//String to boolean conversion
boolean theValue = Boolean.parseBoolean(strBoolean);
System.out.println(theValue);
}
}
//true
Boolean: String toString()
public class Main {
public static void main(String[] args) {
Boolean b = Boolean.valueOf("true");
System.out.println(b.toString());
}
}
Boolean: valueOf(String stringValue)
/*
* Output:
true
c
12
2
13245
12341234
11234.123
4.321324123412341E10
*/
public class MainClass {
public static void main(String args[]) {
Boolean bool = Boolean.valueOf("true");
Character c = new Character("c");
Byte b = Byte.valueOf("12");
Short s = Short.valueOf("2");
Integer i = Integer.valueOf("13245");
Long l = Long.valueOf("12341234");
Float f = Float.valueOf("11234.1234");
Double d = Double.valueOf("43213241234.123412341234");
System.out.println(bool);
System.out.println(c);
System.out.println(b);
System.out.println(s);
System.out.println(i);
System.out.println(l);
System.out.println(f);
System.out.println(d);
}
}
new Boolean(boolean value)
public class Main {
public static void main(String[] args) {
Boolean b1 = new Boolean(false);
Boolean b2 = new Boolean("true");
System.out.println(b1.booleanValue());
System.out.println(b2.booleanValue());
}
}
new Boolean(String s)
public class Main {
public static void main(String[] args) {
Boolean b1 = new Boolean(false);
Boolean b2 = new Boolean("true");
System.out.println(b1.booleanValue());
System.out.println(b2.booleanValue());
}
}