Data type in/**java */
public class demo03{
static Boolean B; Member variables: In-body methods the out-of-body scope is the entire class. When used, the default value can be executed without assigning a value
public static void Main (String []args) {
System.out.println (Math.PI);
Boolean b;//declares that the declaration of the same variable in a method can only be used once
B = true; Assign value
System.out.println (the value of "B" is: "+b);
b = false;
System.out.println (the value of "B" is: "+b);
Final Boolean cc = TRUE; A measure called constant that is decorated by final
System.out.println (the value of "C is:" +CC);
CC = false;//Error: Cannot assign a value to the final variable cc
char c = ' a ';
System.out.println ("C:" +c);
Char C1 = 97;//ansi 0-65535
SYSTEM.OUT.PRINTLN ("C1:" +C1);
char c2 = ' \u0000 ';
System.out.println ("C2:" +C2);
Long l =1l;
float f =1.0f;
Double D1 = 1.0;
String name = "Wangxiao";
String dd = name+ "" +l+ "" +f+ "" +D1;
SYSTEM.OUT.PRINTLN (DD);
Type conversions
byte BB = 104;
int i = BB; Byte-->int small data types will automatically transform to big data types
System.out.println ("Byte small-->int Large" +i);
Long L1 = 1;
int i1 = (int) L1; Large data types are transformed into small data types, and small data types are required to undertake. Boolean type cannot be converted, char type automatically upward to int
System.out.println ("Long Big-->int Small" +i1);
Float F1 = (float) 1.0;
float F2 = 1.0f; F1 in F2 same role
Above already declared char C = ' a ';
int i2 = C;//char auto Go int
System.out.println ("Char c= ' a '-->int:" +i2);
}
}
Data types in Java