上一页 1 ··· 36 37 38 39 40 41 42 43 44 ··· 111 下一页
摘要: public interface A { public void func();}public class B implements A { public B() { // TODO Auto-generated constructor stub } @Override public void func() { // TODO Auto-g... 阅读全文
posted @ 2020-09-04 18:50 thomas_blog 阅读(108) 评论(0) 推荐(0)
摘要: public class A { int i; public A() { // TODO Auto-generated constructor stub } class B { int j; int add() { return i + j; } }}public class Test { ... 阅读全文
posted @ 2020-09-04 18:04 thomas_blog 阅读(154) 评论(0) 推荐(0)
摘要: public interface Person { void introduce();}public class Student implements Person { public Student() { // TODO Auto-generated constructor stub } public void introduce() { Sy... 阅读全文
posted @ 2020-09-04 16:16 thomas_blog 阅读(153) 评论(0) 推荐(0)
摘要: 使用try…catchpublic class Test { public Test() { // TODO Auto-generated constructor stub } public static void main(String[] args) { // TODO Auto-generated method stub try {... 阅读全文
posted @ 2020-09-02 16:56 thomas_blog 阅读(173) 评论(0) 推荐(0)
摘要: 定义使用interface定义接口当中的方法都是抽象方法接口当中的方法都是public权限实现实现接口使用implements关键字一个类可以实现多个接口一个接口可以继承多个接口一个类可以实现多个接口public interface USB { void read(); void write();}public interface WiFi { void open(); v... 阅读全文
posted @ 2020-09-02 15:37 thomas_blog 阅读(836) 评论(0) 推荐(0)
摘要: public同一个包当中,或者不同包当中的类都可以自由访问private只能在本类中使用default(不写权限修饰符,就是default权限)在同一个包当中可以自由访问包导入import使用其他包中的类的时候,不用再使用全名导入单个类import top.zxc.Test导入整个包中所有类import top.zxc.* 阅读全文
posted @ 2020-09-02 14:21 thomas_blog 阅读(136) 评论(0) 推荐(0)
摘要: 防止类重名包名命名规则所有字母小写域名倒过来写一个类的全名“包名”+”.”+”类名”public class Test { public Test() { // TODO Auto-generated constructor stub } public static void main(String[] args) { // TODO Auto-gen... 阅读全文
posted @ 2020-09-02 13:11 thomas_blog 阅读(163) 评论(0) 推荐(0)
摘要: 使用abstract定义的类抽象类不能够生成对象如果一个类中包含抽象函数,那么这个类必须被声明为抽象类如果一个类中没有抽象函数,那么这个类也可以被声明为抽象类抽象类天生就是爹抽象函数必须在子类中复写abstract public class Person { String name; int age; Person() { System.out.println("P... 阅读全文
posted @ 2020-09-01 23:49 thomas_blog 阅读(198) 评论(0) 推荐(0)
摘要: 包括向上转型和向下转型向上转型将子类的对象赋值给父类的引用一个引用能够调用哪些成员(变量和函数),取决于这个引用的类型一个引用调用的是哪个方法,取决于这个引用所指向的对象public class Person { String name; int age; Person(String name, int age) { this.name = name; ... 阅读全文
posted @ 2020-09-01 19:04 thomas_blog 阅读(244) 评论(0) 推荐(0)
摘要: 子类对introduce进行复写public class Person { String name; int age; Person(String name, int age) { this.name = name; this.age = age; System.out.println("Person 二参构造"); } vo... 阅读全文
posted @ 2020-09-01 13:08 thomas_blog 阅读(357) 评论(0) 推荐(0)
上一页 1 ··· 36 37 38 39 40 41 42 43 44 ··· 111 下一页