摘要: 数组的遍历,读取数组的值 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)
摘要: 构造方法的重载跟方法的重载差不多,看看代码就可以了,没有什么过多的解释 public class Uer { int id; String name; String pwd; public Uer() { } public Uer(int id, String name) { this.id = i 阅读全文
posted @ 2021-08-20 11:30 许我半盏清茶 阅读(32) 评论(0) 推荐(0)
摘要: 恢复内容开始 可以先看下面的代码(输出“帝豪装饰”是因为我当时在这个装修公司上班,然后自学Java,输出内容不重要) public class Demo02 { public static void main(String[] args) { Demo02 de = new Demo02(); de 阅读全文
posted @ 2021-08-18 16:00 许我半盏清茶 阅读(72) 评论(0) 推荐(0)