摘要:
数组的遍历,读取数组的值 public class Test02 { public static void main(String[] args) { int[]a = new int [4]; //初始化数组元素的值 for(int i =0;i<a.length;i++) { a[i] = 10 阅读全文
posted @ 2022-03-11 14:10
许我半盏清茶
阅读(35)
评论(0)
推荐(0)
摘要:
//天朝有一个乞丐姓洪,去天桥要钱//第一天要了1块钱//第二天要了2块钱//第三天要了4块钱//第四天要了8块钱//以此类推//问题: 洪乞丐干10天,收入是多少? public class TestFor { public static void main(String[] args) { in 阅读全文
posted @ 2022-03-11 14:09
许我半盏清茶
阅读(71)
评论(0)
推荐(0)
摘要:
import java.util.Scanner; //从键盘输入时要导入的Scanner包 public class TestWhile { public static void main(String[] args) { Scanner s = new Scanner(System.in); S 阅读全文
posted @ 2022-03-11 14:09
许我半盏清茶
阅读(109)
评论(0)
推荐(0)
摘要:
continue的用途是忽略这一次的循环,继续下一次循环,可以用来忽略不想要的部分; public class TestContinue { public static void main(String[] args) { for (int i = 1; i <= 100; i++) { //循环1 阅读全文
posted @ 2022-03-11 11:54
许我半盏清茶
阅读(509)
评论(0)
推荐(0)
摘要:
继承是子类继承父类的属性和方法,也可以重写父类的方法得到自己想要的方法 public class TestOverride { public static void main(String[] args) { Horse h = new Horse(); h.run(); //调用run方法 }}c 阅读全文
posted @ 2022-03-11 11:54
许我半盏清茶
阅读(115)
评论(0)
推荐(0)
摘要:
方法的重载在于通过不同的形参调用不同的方法(形参的个数,类型等不同),这样可以随时调用自己想要的方法 public class TestOverload { public static void main(String[] args) { System.out.println(add(40, 50) 阅读全文
posted @ 2022-03-11 11:53
许我半盏清茶
阅读(21)
评论(0)
推荐(0)