摘要: package com.karl2; public class MethoOverDemo { public static void main(String[] args) { //方法重载 kokoko(); sasasa(100); fire(); fire("米国"); fire("米国",9 阅读全文
posted @ 2023-05-28 11:43 Karlshell 阅读(11) 评论(0) 推荐(0)
摘要: package com.karl2; public class MethoDemo2 { public static void main(String[] args) { //方法在类中的位置放前后无所谓,但一个方法不能放在另一个方法里面 //return语句的下面,不能编写代码,属于无效代码,执行 阅读全文
posted @ 2023-05-28 11:42 Karlshell 阅读(44) 评论(0) 推荐(0)
摘要: package com.karl2; public class MethoDemo { public static void main(String[] args) { //打印6行 print(6); //打印3行 print(3); } //如果方法不需要返回数据,返回值类型必须申明成void( 阅读全文
posted @ 2023-05-28 11:41 Karlshell 阅读(94) 评论(0) 推荐(0)
摘要: package com.karl2; public class MethodDemo { public static void main(String[] args) { //方法是一种语法结构,它可以把一段代码封装成一个功能,以便重复调用 //1.调用方法 int rs=sum(10,20); S 阅读全文
posted @ 2023-05-28 11:40 Karlshell 阅读(12) 评论(0) 推荐(0)
摘要: package com.karl; public class WhileDemo { public static void main(String[] args) { //功能上和for完全一样,for能解决的while也能解决反之亦然 //使用规范:知道循环几次用for,不知道循环几次建议使用wh 阅读全文
posted @ 2023-05-28 11:39 Karlshell 阅读(34) 评论(0) 推荐(0)
摘要: package com.karl; //if在功能上远远强大于switch //当前条件是区间的时候,应该使用if分支结构 //switch适合做:条件是比较值的情况,代码优雅,性能较好 public class SwitchDemo { public static void main(String 阅读全文
posted @ 2023-05-28 11:39 Karlshell 阅读(22) 评论(0) 推荐(0)
摘要: package com.karl; public class sixunhuanDemo { public static void main(String[] args) { //死循环3种写法 /*1.for for (;;){ System.out.println("ko"); } */ //经 阅读全文
posted @ 2023-05-28 11:38 Karlshell 阅读(99) 评论(0) 推荐(0)
摘要: package com.karl; import java.util.Random; public class RandomDemo { public static void main(String[] args) { //创建一个Random对象,用于生成随机数 Random r=new Rand 阅读全文
posted @ 2023-05-28 11:37 Karlshell 阅读(18) 评论(0) 推荐(0)
摘要: package com.karl; public class loopnestedDemo { public static void main(String[] args) { //外部循环每循环一次,内部循环会全部执行完一轮 //嵌套循环 for (int i = 1; i <= 3; i++) 阅读全文
posted @ 2023-05-28 11:36 Karlshell 阅读(53) 评论(0) 推荐(0)
摘要: package com.karl; public class guanjianziDemo { public static void main(String[] args) { //break:跳出并结束所在循环的执行 //只能用于结束所在循环,或者结束switch分支的执行 //continue: 阅读全文
posted @ 2023-05-28 11:36 Karlshell 阅读(17) 评论(0) 推荐(0)