12 2020 档案
Java this关键字的使用场景
摘要:this的概念: this保存当前对象的内存地址,指向自身; this保存在堆内存的对象中; this用来访问实例变量 ,表示当前对象,所以this不使用于静态方法中,可以省略; public class ThisTest02{ public static void main(String[] ar 阅读全文
posted @ 2020-12-27 22:52 homle 阅读(383) 评论(0) 推荐(0)
Java 静态代码块和实例代码块
摘要:静态代码块的使用: 示例一: public class StaticTest03{ static{ System.out.println("A"); } static{ System.out.println("B"); } public static void main(String[] args) 阅读全文
posted @ 2020-12-23 22:42 homle 阅读(248) 评论(0) 推荐(0)
Java 空引用访问静态不会发生空指针异常
摘要:public class StaitcTest02{ public static void main(String[] args){ Chinese c1 = new Chinese("11111111","zhang","中国"); System.out.println(c1.idCard); S 阅读全文
posted @ 2020-12-20 13:10 homle 阅读(303) 评论(0) 推荐(0)
Java 什么时候使用static
摘要:1 .先不使用static public class StaticTest{ public static void main(String[] args){ Chinese c1 = new Chinese("11111111","zhang","中国"); System.out.println(c 阅读全文
posted @ 2020-12-20 12:49 homle 阅读(1280) 评论(0) 推荐(0)
Java 空指针异常
摘要:public class NullPointer{ public static void main(String[] args){ Customer c = new Customer(); System.out.println(c.id); //0 c.id = 1213; System.out.p 阅读全文
posted @ 2020-12-13 11:00 homle 阅读(190) 评论(0) 推荐(0)