Integral type
public static void Thenumber () {
BYTE BYTE1=127;//1 byte 8-bit -128--127
Short SHORT=1200;//2 bytes 16 bit
int NUM1=1200;//8 byte 32 bit
Long NUM2=121L;//8 byte 64 bit long type recommended plus l
int num3=0b0000_0000_0000_0000_0000_0000_0000_0011;//jdk1.7 binary Representation 3
int num4=1234_1234;//jdk1.7 12341234
System.out.println (NUM3);
}
Binary conversion
public static void Scalenumber () {
int num1=10;
String num2=integer.tobinarystring (NUM1);//Convert to 2 binary
String num3=integer.tooctalstring (NUM1);//Convert to Octal
String num4=integer.tohexstring (NUM1);//Convert to 16 binary
}
Floating-point type floating-point type constants are double by default
public static void floating () {
Double d=3.14; 8 bytes
Float f=3.14f;//4 bytes
Double d2=10e-2;//scientific Counting method 0.1
Floating-point numbers lose precision if requirements are strict, the use of floating-point type constants is double by default
float f1=0.1f;
Double D3=1/10;
}
Character type
public static void character () {
Char c1= ' q ';
Char c2= ' in ';//unicode 2 bytes: 0-65535
Char c3= ' \ ';//\ is the output of the signifier character '
Char c4= ' \ n ';//turn meaning to indicate line break
Char c5= ' a ';
int n=c5+2;//99 ASCII Code
Char c6= (char) n;//integer to Char
Cycle Print A-Z
for (int i=0;i<26;i++) {
Char temp= (char) (' a ' +i);
SYSTEM.OUT.PRINTLN (temp);
}
In Java, strings are defined as string types.
String str= "ABCDEFG";
}
Yes/No
public static void whether () {
Boolean boo=false;//1 bytes
}
Java Basic data types