Day 3 变量、运算符
变量
package base;
public class demo08 {
static double salary =2500;
String name;
int age;
public static void main(String[] args) {
int i =10;
System.out.println(i);
demo08 demo08 = new demo08();
System.out.println(demo08.age);
System.out.println(demo08.name);
System.out.println(salary);
}
public void add(){
}
}
package base;
public class demo09 {
static final double PI =3.14;
public static void main(String[] args) {
System.out.println(PI);
}
}
运算符
package operater;
public class Demo01 {
public static void main(String[] args) {
int a = 10;
int b = 20;
int c = 30;
int d = 40;
System.out.println(a+b);
System.out.println(a-b);
System.out.println(a*b);
System.out.println(a/(double)b);
}
}
package operater;
public class Demo02 {
public static void main(String[] args) {
long a = 123123123123L;
int b =123;
short c =10;
byte d = 8;
System.out.println(a+b+c+d);
System.out.println(b+c+d);
System.out.println(c+d);
}
}
package operater;
public class Demo03 {
public static void main(String[] args) {
int a = 10;
int b = 20;
int c = 21;
System.out.println(a<b);
System.out.println(a>b);
System.out.println(a==b);
System.out.println(a!=b);
System.out.println(c%a);
}
}
package operater;
public class Demo04 {
public static void main(String[] args) {
int a = 3;
int b =a++;
System.out.println(a);
int c =++a;
System.out.println(a);
System.out.println(b);
System.out.println(c);
}
}
package operater;
public class Demo05 {
public static void main(String[] args) {
boolean a = true;
boolean b = false;
System.out.println("a&&b:"+(a&&b));
System.out.println("a||b:"+(a||b));
System.out.println("!(a&&b):"+!(a&&b));
int c =5;
boolean d = (c<4)&&(c++<4);
System.out.println(d);
System.out.println(c);
}
}
package operater;
public class Demo06 {
public static void main(String[] args) {
System.out.println(2<<3);
}
}
package operater;
public class Demo08 {
public static void main(String[] args) {
int score = 80;
String type = score <60 ?"不及格":"及格";
System.out.println(type);
}
}
变量的命名规范