java程序设计学习
1、赋值运算符:int num=8;
2、变量
格式
数据类型 变量名=数据值;
数据类型 变量名;
变量名=数据值。
3、学习基本数据类型
(①整数类型:byte、short、int、long;
②浮点类型:float、double;
③字符类型:char;
④布尔类型:boolean.
)
int num1;
num1=5;
System.out.println(num1);
byte num3=30;
System.out.println(num3);
short num4=50;
System.out.println(num4);
long num5=3000000000L;
System.out.println(num5);
double num6=3.14;
System.out.println(num6);
float num7=3.14F;
System.out.println(num7);
char var1=‘A’;
System.out.println(var1);
boolean var3=true;
System.out.println(var3);
4、变量名唯一
(float F long L )
float num7=3.14F;
System.out.println(num7);
long num5=3000000000L;
System.out.println(num5);
float num3=3.14F;
System.out.println(num3);
double num4=3.14F;
System.out.println(num4);
float num5=30L;
System.out.println(num5);
long num6=30L;
System.out.println(num6);
int num7=(int)100L;
System.out.println(num7);
int num8=(int)6000000000L;
5、四则运算(+、-、、/、%)
int a=1;
int b=2;
System.out.println(a+b);
System.out.println(a-b);
System.out.println(ab);
System.out.println(a/b);
int x=8;
int y=2;
System.out.println(x/y);
double resultl=x/y;
System.out.println(resultl);
int resultl2=x%y;
System.out.println(resultl2);
double z=9.0;
double resultl3=x+z;
System.out.println(resultl3);
2021-03-11
最新推荐文章于 2021-11-21 12:10:25 发布