上一页 1 ··· 20 21 22 23 24 25 26 27 28 ··· 133 下一页
摘要: ``` interface IEat { // 定义核心业务标准 public void get(); // 业务方法 } class EatReal implements IEat { // 定义真实主题类 public void get(){ System.out.println("【真实主题】 阅读全文
posted @ 2023-06-10 22:42 盘思动 阅读(27) 评论(0) 推荐(0)
摘要: ### demo1 ``` interface IFood { public abstract void eat(); } class Bread implements IFood { public void eat(){ System.out.println("吃面包~"); } } class 阅读全文
posted @ 2023-06-10 22:04 盘思动 阅读(14) 评论(0) 推荐(0)
摘要: ``` interface IUSB { public boolean check(); public void work(); } class Computer { public void plugin(IUSB usb){// 电脑上使用USB设备 ??什么格式 if(usb.check()){ 阅读全文
posted @ 2023-06-10 16:56 盘思动 阅读(15) 评论(0) 推荐(0)
摘要: * default,static不可作为主要的设计模式,这个只是补救措施。 ### demo1 接口中追加普通方法 接口定义方法加上default,子类实现就不是非得覆写了 ``` interface IMessage { public String message();// 抽象方法,abstra 阅读全文
posted @ 2023-06-10 16:15 盘思动 阅读(15) 评论(0) 推荐(0)
摘要: ### demo1 接口简单基本定义 ``` interface IMessage {// 定义接口 public static final String INFO = "www.baidu.com";// 全局常量 public abstract String getInfo(); } class 阅读全文
posted @ 2023-06-10 10:32 盘思动 阅读(29) 评论(0) 推荐(0)
摘要: * 包装类除了有引用支持外,还提供数据类型转换功能 ### demo1 字符串转数值 ``` String str = "123"; int num = Integer.parseInt(str);// 字符串转为int 转换过程中,字符串必须都由数组组成,否则报错!!!(NumberFormatE 阅读全文
posted @ 2023-06-10 09:24 盘思动 阅读(15) 评论(0) 推荐(0)
摘要: ### demo1 integer ,int 为例实现转换 ``` Integer obj = new Integer(10);// 装箱 int num = obj.intValue();// 拆箱 System.out.println(num * num); ``` ### demo2 doub 阅读全文
posted @ 2023-06-09 17:15 盘思动 阅读(10) 评论(0) 推荐(0)
摘要: * 为了统一参数传输类型,需要针对于基础数据类型实现引用传递,所以java提供了包装类概念。 ## demo1 包装类的简单基础案例 ``` class Int { private int data;// 包装类一个基本数据类型 public Int(int data){ this.data = d 阅读全文
posted @ 2023-06-09 16:56 盘思动 阅读(28) 评论(0) 推荐(0)
摘要: * 抽象类的设计应该是比类更高一层的设计。 * 抽象类最大好处:1.对子类方法对统一管理;2.可以自身提供有一些普通方法,并且这些普通方法可以调用抽象方法(这些抽象方法必须在有子类提供实现的时候才会生效) ![](https://img2023.cnblogs.com/blog/1202393/20 阅读全文
posted @ 2023-06-09 14:48 盘思动 阅读(16) 评论(0) 推荐(0)
摘要: * 抽象类铁律:不能实例化!!!!! ## demo1 抽象类可以提供构造方法的; ``` abstract class Message {// 定义抽象类; private String type; // 此抽象类中没有提供无参构造,所以子类必须明确调用单参构造 public Message(St 阅读全文
posted @ 2023-06-09 13:49 盘思动 阅读(27) 评论(0) 推荐(0)
上一页 1 ··· 20 21 22 23 24 25 26 27 28 ··· 133 下一页