逻辑控制
if(布尔表达式){
}
switch(整数|枚举|字符|字符串){
}
面试:不能做switch 的参数有哪些?
long double float booolean
while(布尔表达式){
}
break:结束所有循环
continue
for(表达式1;表达式2;表达式3){} 表达式2为布尔类型
system.in:输入
system.out:输出
编译时期的异常,必须处理之后,才能使用。
注意:
1.在java中没有什么方法需要声明
2.只有按值传递 (引用———>低配的指针)
重载:
1.函数名相同
2.参数列表不同(类型和个数)
3.返回值类型不做要求
4.必须在同一个类当中或者在继承关系上
import java.util.Scanner
//导入包 util 工具类
public static void main(String[] args){
Scanner cool=new Scanner(System.in);
System.out.println(msg); // 输出一个字符串, 带换行
System.out.print(msg); // 输出一个字符串, 不带换行
System.out.printf(format, msg); // 格式化输出(与c里相同)
cool.close;//关闭之后就不能使用。
//ctr+c 正常的停止程序
//ctr+z
for(int i=0; ;i++){
System.out.println(i);
}//死循环
}