输入输出
Scanner中nextLine可接受空格,next不接收
键盘接收:数字+字符:要输入两个nextline,第一个是为了回车,next则只要一个
System.out.println是小写的L,不是大写的i
输出:
System.out.println
System.out.printf:usage is the same with c
System.out.print.
两个println 换行
print不会换行
语言符号:
类名首字母大写
变量名和方法名,第一个单词小写,其余大写
标识符:
常量完全大写,用"_"
// 注释
/*多行注释 */
/** 文档注释*/:可以提取出来,形成html的程序文档
提取注释文档:
javadoc -d html文档存放 *** ***
必须要有pubilc类才能提取
类型转化
byte 字符(-128-127)所以过大的数强制转化会失真
int float(默认double) double boolean
符合数据类型:
class Student
{
int age;
float height;
}
基本类行变量和引用类行变量
引用类型,只开辟空间,不开辟数据空间,不能开辟数据。
Student stu; //开辟引用空间
stu.age=2 //错误
修改
stu = new Student();
运算符与表达式:
== != 优先级低于 <= >= > < =
&&(短路与) ||(短路或) !
priority: !>&&>||
?: 同c++
&按位与 对应位全为1才为1
| 按位或 对应位全为0才为0
-
^ 按位异或
- 按位非
<< 左移 右边补0
int a=7;a<<2是多少
7->111, 11100->28