class VariableTest1{
public static void main(String[] args){
//1.整型
//byte范围 -128 - 127
byte b1 = 12;
byte b2 = -128;
//byte b2 = 128编译不通过
System.out.println(b1);
System.out.println(b2);
//声明long型变量,必须以"L"或"I"结尾
short s1 = 128;
int i1 = 1234;
long l1 = 41423551531413L;
System.out.println(l1);
//2.浮点型
double d1 = 123.3;
System.out.println(d1);
float d2 = 12.3F;
System.out.println(d2);
//3.字符型: char(1字符 = 2字节)
//1. 定义char型变量,通常使用一对'',内部只能写一个字符
char c1 = 'a';
// c1 = 'AB' 编译不通过
System.out.println(c1);
char c2 = '1';
char c3 = '中';
System.out.println(c2);
System.out.println(c3);
// 表示方式 1.声明一个字符 2.转义字符
String a1 = "Hello";
String a2 = "World!";
System.out.println(a1 + '\t' + a2);
char c4 = '\u0043';
System.out.println(c4);
//4.布尔型 boolean
//只能取两个值 true false
//常常在条件判断。循环结构中使用
boolean bb1 = true;
System.out.println(bb1);
boolean isMarried = true;
if(isMarried){
System.out.println("你就不可以参加\"单身party\"了!\n很遗憾");
}else{
System.out.println("你就可以多谈女朋友");
}
}
}