摘要: 面向对象-参数和返回值 <1>类名作为参数和返回值 方法的形参是类名,就是需要该类的对象. 方法的返回值是类名,就是返回一个该类的对象. //猫类 public class Cat { public void eat(){ System.out.println("猫吃鱼."); } } // //操 阅读全文
posted @ 2023-02-01 11:06 大宝贝94106 阅读(33) 评论(0) 推荐(0)
摘要: 面向对象-接口-2 //接口1 public interface Inter1 { } // //接口2 public interface Inter2 { } // //接口3 public interface Inter3 extends Inter1,Inter2{ //接口和接口是继承关系, 阅读全文
posted @ 2023-01-30 10:13 大宝贝94106 阅读(22) 评论(0) 推荐(0)
摘要: 面向对象-接口-1 // 接口类 public interface jumpping { void jump(); } // // 动物类 public abstract class animal { private String name; private int age; public anim 阅读全文
posted @ 2023-01-29 21:46 大宝贝94106 阅读(75) 评论(0) 推荐(0)
摘要: 面向对象-抽象类-1 // 父类 动物 public abstract class Animal { //抽象类要用abstract关键字 //abstract关键字要类和方法的权限修饰符后面!@@@ public abstract void eat(); //抽象方法没有具体的方法体 public 阅读全文
posted @ 2023-01-29 11:44 大宝贝94106 阅读(29) 评论(0) 推荐(0)
摘要: 面向对象-多态-2 //父类 动物 public class Animal { public void eat(){ System.out.println("动物吃东西."); } } // //子类 猫 public class Cat extends Animal { @Override pub 阅读全文
posted @ 2023-01-28 19:44 大宝贝94106 阅读(32) 评论(0) 推荐(0)
摘要: 面向对象-多态-1 public class Animal { public int age=40; public void eat(){ System.out.println("动物吃东西."); } } // public class Cat extends Animal { public in 阅读全文
posted @ 2023-01-26 11:18 大宝贝94106 阅读(23) 评论(0) 推荐(0)
摘要: 面向对象-继承-2 final 最终的 可以用来修饰 类, 方法 ,变量 用来修饰一个类后, 此类不能被其他类继承. 例如: String类, System类, StringBuffer类... 用来修饰一个方法后, 表面此方法不能被重写. 例如: Object中的getClass()方法... 阅读全文
posted @ 2023-01-25 13:50 大宝贝94106 阅读(18) 评论(0) 推荐(0)
摘要: 面向对象-继承-1 public class fu { int age = 19; } // public class zi extends fu{ //在子类中使用extends fu命令,来继承父类 int age = 8; public void ziMethor(){ int age = 2 阅读全文
posted @ 2023-01-24 21:12 大宝贝94106 阅读(18) 评论(0) 推荐(0)
摘要: ArrayList类的常用方法 package heima01; import java.util.ArrayList; /* ArrayList常用方法: public boolean remove(Object o):删除指定的元素,返回删除是否成功 public E remove(int in 阅读全文
posted @ 2023-01-18 15:55 大宝贝94106 阅读(49) 评论(0) 推荐(0)
摘要: 集合基础 import java.util.ArrayList; public class ArrayListDemo_1 { public static void main(String[] args) { ArrayList<String> arrL = new ArrayList<>(); a 阅读全文
posted @ 2023-01-18 15:54 大宝贝94106 阅读(24) 评论(0) 推荐(0)