public class Demo01 {
int num1 = 10;
byte num2 = 20;
short num3 = 30;
long num4 = 30L;
float num5 = 50.1F;
double num6 = 3.14;
char name ='a';
String pw = "wangwang";
boolean flag = true;
}
public class Demo02 {
public static void main(String[] args) {
int i = 10;
int i2 = 010;
int i3 = 0x10;
System.out.println(i);
System.out.println(i2);
System.out.println(i3);
System.out.println("=================================");
float f = 0.1f;
double d = 1.0/10;
System.out.println(f == d);
float d1 = 232323232323f;
float d2 = d1 + 1;
System.out.println(d1 == d2);
System.out.println("===================================");
char c1 = 'a';
char c2 = '光';
System.out.println(c1);
System.out.println((int) c1);
System.out.println(c2);
System.out.println((int) c2);
System.out.println("=====================================");
String sa = new String("Hello World");
String sb = new String("Hello World");
System.out.println(sa == sb);
String sc = "Hello World";
String sd = "Hello World";
System.out.println(sc == sd);
}
}
public class Demo03 {
public static void main(String[] args) {
int i = 128;
byte b = (byte) i;
System.out.println(i);
System.out.println(b);
int j = 128;
double a = j;
System.out.println(j);
System.out.println(a);
int money = 10_0000_0000;
int years = 20;
int total = money * years;
long total2 = money * years;
long total3 = money * ((long)years);
System.out.println(total);
System.out.println(total2);
System.out.println(total3);
}
}
public class Demo04 {
static double money = 100000;
String name;
int age;
public static void main(String[] args) {
int i = 10;
System.out.println(i);
Demo04 demo04 = new Demo04();
System.out.println(demo04.age);
System.out.println(demo04.name);
System.out.println(money);
}
}
public class Demo05 {
static final double PI = 3.14;
public static void main(String[] args) {
System.out.println(PI);
}
}