public class NameRule {
/**
* 标识符:以字母、下划线"_"、或美元符"$"打头,
* 后面可跟数字、字母、下划线、美元符的字符串。
* 包名:全部小写。
* 类名:第一个字母大写。
* 方法名:第一个单词小写,后面单词首字母大写。e.g.
* updatXXX、addXXX、deleteXXX、querXXX
*
* 变量:第一个单词小写,后面单词首字母大写。e.g.
* long longShoutMessage = 0L;
* 常量:全部大写。e.g.
* public final static int MAX_LOOP = 9;
* **/
public void intFun(){
int _int = 10^2; //4字节,正负20多个亿 ?????????
short shortInt = -32768; //2字节,正负几万
long longInt =987654321123456789l; //8字节,老大了(数字后要加L)
System.out.println("intFun: "+_int+", "+shortInt+", "+longInt);
}
public void floatFun(){
float _float = 0.123456789F; //4字节,单精度,7位小数(数字后要加F)
double _double = 0.123456789087654321; //8字节,双精度,16位小数
System.out.println("floatFunm: "+_float+", "+_double);
}
public static void main(String args[]){
//变量的优先级:byte<short<int<long<float<double
byte _byte = 127; //1字节,-128~127
byte _byte1 = (byte)888; //输出120
byte _byte2 = 'a'; //输出整数
char _char = 'A'; //2字节,0~65535
char _char1 = 65; //输出 A
boolean _boolean = true; //1字节,true/false
NameRule obj = new NameRule();
obj.intFun();
obj.floatFun();
System.out.println("variable: "+_byte+", "+_byte1+", "+_byte2+", "+_char+", "+_char1+", "+_boolean);
}
}
java变量基础
最新推荐文章于 2022-06-14 22:16:43 发布