变量类型
变量命名必须以英文为开头
primitive主数据类型
byte,
short,int,long,
double,float,
char,
boolean 只有false和true两值
final关键字用于常量
final int type=0;
type的值不可修改
引用变量
相当于遥控器
基本API
JavaAPI中的类名首字母均大写
String
ArrayList
强化版数组
Math
两个常量PI和E,精度很高(至少比自己手打的高)
一些数学函数,比如求绝对值Math.abs()
求幂运算Math.pow()
,直接.
出来,或查API表,这里就不再赘述了。
此外,Math是一个静态的类,这里简单介绍一下静态成员变量和静态成员函数
比如说Math中有
public static final double PI=3.141592653589793;
public static final double E=2.718281828459045;
里面的static
表示该常量是静态的,属于类,每个类只有一个这样的静态域,意思就是说,每个对象对实例域都有一份自己的拷贝,而静态域属于类。
另外,静态的方法只能调用静态的变量,而不能调用非静态的,另外,不能通过对象调用静态方法,只能通过类来调用,比如:
class tst{
private static int test;
public static int gettest(){
return test;
}
}
class testtst{
public static void main(String args){
System.out.println(tst.gettest());
}
}
因此我们不需要创建Math对象就可以调用Math的方法了。