case,switch case,,,,case有穿透。。在switch语句中,如果case控制语句体后面不写break,将会出现穿透现象。
在不判断下一个case的情况下,向下运行直到 遇见break,或者整体switch语句结束。
三种循环:for、while、do。。while
for和while循环先判断条件是否成立,然后决定是否执行循环体(先判断后执行)
do。。while循环先执行一次循环体,然后判断条件是否成立,(先判断后执行)
在不判断下一个case的情况下,向下运行直到 遇见break,或者整体switch语句结束。
三种循环:for、while、do。。while
for和while循环先判断条件是否成立,然后决定是否执行循环体(先判断后执行)
do。。while循环先执行一次循环体,然后判断条件是否成立,(先判断后执行)
for和while循环的区别:条件控制语句中的自增变量,因为归属for循环,所以结束循环,就不允许调用。
while循环的控制语句自增变量,在while体外,可以继续使用。。
死循环格式:for(;;){}
while(true){}
do{}while(true)
continue:用在循环中,基于条件控制,跳过某次循环体内容的执行。继续下一次。。。
break:用在循环体中,基于条件控制,终止循环体内容,结束当前的整个循环。。。
while循环的控制语句自增变量,在while体外,可以继续使用。。
死循环格式:for(;;){}
while(true){}
do{}while(true)
continue:用在循环中,基于条件控制,跳过某次循环体内容的执行。继续下一次。。。
break:用在循环体中,基于条件控制,终止循环体内容,结束当前的整个循环。。。
数组的定义:
int[] arr=new int[3];
左边
int:说明数组中的元素类型是int类型。
[]:说明这是一个数组
arr:这是这个数组的名称
右边
new:为数组开辟内存空间
int:数组里面的数据类型
[]:说明这是个数组
3:数组的长度,就是数组的元素个数。
int[] arr=new int[3];
左边
int:说明数组中的元素类型是int类型。
[]:说明这是一个数组
arr:这是这个数组的名称
右边
new:为数组开辟内存空间
int:数组里面的数据类型
[]:说明这是个数组
3:数组的长度,就是数组的元素个数。
Java中的内存分配
·~栈:存储局部变量 类似于 int[] arr
定义在方法中的变量,使用完毕,立刻消失。
·~堆:存储new出来的内容(实体,对象) 类似于 new int[3]
数组在初始化时,会为存储空间添加默认值。
整数:0 浮点:0.0 布尔:false 字符:空字符 引用数据类型:null
每一个new出来的东西都有地址值,使用完毕,会在垃圾回收器空闲时被回收。
·~栈:存储局部变量 类似于 int[] arr
定义在方法中的变量,使用完毕,立刻消失。
·~堆:存储new出来的内容(实体,对象) 类似于 new int[3]
数组在初始化时,会为存储空间添加默认值。
整数:0 浮点:0.0 布尔:false 字符:空字符 引用数据类型:null
每一个new出来的东西都有地址值,使用完毕,会在垃圾回收器空闲时被回收。
数组的遍历:arr.length
获取数组最值: 定义一个变量,获取最大值。逐个比较