01 2024 档案

摘要://自定义异常类public class MyException extends Exception{ //传递数字》10 private int detail;​ public MyException(int a) { this.detail = a; }​ @Override public St 阅读全文
posted @ 2024-01-24 09:49 fightownself 阅读(3) 评论(0) 推荐(0) 编辑
摘要:public class Demo01 { public static void main(String[] args) { int a =1; int b =0; //ctrl+alt+T //假设要捕获多个异常:从小到大 try {//监控区域 new Demo01().a(); } catch 阅读全文
posted @ 2024-01-23 11:58 fightownself 阅读(28) 评论(0) 推荐(0) 编辑
摘要:public class Outer { private int id =10; public void out(){ System.out.println("这是外部类的方法"); } public class Inner{ public void in() { System.out.printl 阅读全文
posted @ 2024-01-23 10:50 fightownself 阅读(27) 评论(0) 推荐(0) 编辑
摘要:接口的本质就是契约 作用: 约束 定义一些方法,让不同的人实现 public abstract public static final 接口不能实例化,接口中没有构造方法 implements可以实现多个接口 必须重写接口中的方法 //定义的关键字 interface ,接口都需要有实现类publi 阅读全文
posted @ 2024-01-23 10:09 fightownself 阅读(3) 评论(0) 推荐(0) 编辑
摘要://抽象类 类:extends:单继承 接口可以多继承public abstract class Action { //abstract 抽象方法 只有方法名字,没有实现的效果 public abstract void doSomething(); //1.不能new这个抽象类,只能靠子类去实现它: 阅读全文
posted @ 2024-01-19 15:14 fightownself 阅读(5) 评论(0) 推荐(0) 编辑
摘要:public class Application { public static void main(String[] args) { //Object >String //Object >Person>Student //Object >Person>Teacher //System.out.pr 阅读全文
posted @ 2024-01-18 17:48 fightownself 阅读(5) 评论(0) 推荐(0) 编辑
摘要:public class Application { public static void main(String[] args) { //一个对象的实际类型是确定的 //可以指向的引用类型就不确定了:父类的引用指向了子类 //Student 能调用的方法都是自己的或者继承父类的 Student s 阅读全文
posted @ 2024-01-18 10:58 fightownself 阅读(5) 评论(0) 推荐(0) 编辑
摘要:super注意点 super调用父类的构造方法,必须在构造方法的第一个 super必须只能出现在子类的方法或者构造方法中 super和this 不能同时调用构造方法 this 代表的对象不同: this :本身调用者这个对象 super:代表父类对象的应用 前提 this:没有继承也可以使用 sup 阅读全文
posted @ 2024-01-17 16:52 fightownself 阅读(3) 评论(0) 推荐(0) 编辑
摘要:super注意点 super调用父类的构造方法,必须在构造方法的第一个 super必须只能出现在子类的方法或者构造方法中 super和this 不能同时调用构造方法 this 代表的对象不同: this :本身调用者这个对象 super:代表父类对象的应用 前提 this:没有继承也可以使用 sup 阅读全文
posted @ 2024-01-17 11:58 fightownself 阅读(10) 评论(0) 推荐(0) 编辑
摘要:继承 //java中所有的类,都默认继承直接或者间接继承object//Person :人 父类//java中只有单继承没有多继承public class Person { private int money = 10_0000_0000;​ public int getMoney() { retu 阅读全文
posted @ 2024-01-17 10:35 fightownself 阅读(3) 评论(0) 推荐(0) 编辑
摘要:属性私有,get/set public class Application { public static void main(String[] args) { /* * 1.提高程序的安全性,保护数据 * 2.隐藏代码的实现细节 * 3.统一接口 * 4.提高了系统的维护性 * */ Studen 阅读全文
posted @ 2024-01-16 16:50 fightownself 阅读(6) 评论(0) 推荐(0) 编辑
摘要:public static void main(String[] args) { Person person = new Person("zhangsan",23); System.out.println(person.name); System.out.println(person.age);} 阅读全文
posted @ 2024-01-15 17:28 fightownself 阅读(4) 评论(0) 推荐(0) 编辑
摘要:类和对象的创建 public static void main(String[] args) { //类:抽象化,实例化 //类实例化会返回一个自己的对象 //student对象就是一个Student类的具体实例 Student xiaoming = new Student(); Student x 阅读全文
posted @ 2024-01-15 16:37 fightownself 阅读(4) 评论(0) 推荐(0) 编辑
摘要:稀疏数组 public static void main(String[] args) { //1.创建一个二维数组 11*11 0:没有棋子 1:黑棋 2:白棋 int[][] array1 = new int[11][11]; array1[1][2] = 1; array1[2][3] = 2 阅读全文
posted @ 2024-01-12 11:11 fightownself 阅读(41) 评论(0) 推荐(0) 编辑
摘要:冒泡排序 public static void main(String[] args) { int[] a = {1,3,5,34,56,34,78}; int[] sort = sort(a);//调用完我们自己写的排序方法后,返回一个排序后的数组 System.out.println(Array 阅读全文
posted @ 2024-01-09 10:17 fightownself 阅读(31) 评论(0) 推荐(0) 编辑
摘要:二维数组 public static void main(String[] args) { //二维数组 /* * 1,2 array[0] * 2,3 array[1] * 3,4 array[2] * 4,5 array[3] * */ int[][] array={{1,2},{2,3},{3 阅读全文
posted @ 2024-01-04 17:46 fightownself 阅读(4) 评论(0) 推荐(0) 编辑
摘要:反转数组 public static void main(String[] args) { int[] arrays = {1,2,3,4,5}; int[] reverse = reverse(arrays); printArray(reverse); } //反转数组 public static 阅读全文
posted @ 2024-01-04 17:24 fightownself 阅读(11) 评论(0) 推荐(0) 编辑
摘要:数组的定义 变量的类型 变量的名字 = 变量的值 数组的类型 public static void main(String[] args) { // 变量的类型 变量的名字 = 变量的值 //数组的类型 int[] nums;//1.声明一个数组 nums = new int[10];//2.创建一 阅读全文
posted @ 2024-01-04 16:08 fightownself 阅读(7) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示