摘要: package com.Demo1; public class Test { public static void main(String[] args) { //掌握在类的构造器中,通过this(...)调用兄弟构造器的作用 Student s1=new Student("李四",26,"家里蹲大 阅读全文
posted @ 2023-05-28 18:42 Karlshell 阅读(30) 评论(0) 推荐(0)
摘要: package com.Demo1; public class Test { public static void main(String[] args) { //搞清楚子类构造器为什么要调用父类构造器,有啥应用场景 Teacher t=new Teacher("李四",36,"Java"); Sy 阅读全文
posted @ 2023-05-28 17:17 Karlshell 阅读(17) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2023-05-28 17:02 Karlshell 阅读(14) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2023-05-28 16:55 Karlshell 阅读(12) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2023-05-28 16:47 Karlshell 阅读(12) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2023-05-28 16:30 Karlshell 阅读(20) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2023-05-28 16:23 Karlshell 阅读(10) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2023-05-28 16:15 Karlshell 阅读(15) 评论(0) 推荐(0)
摘要: package com.extendsDemo; public class Test { public static void main(String[] args) { B b=new B(); System.out.println(b.i); // System.out.println(b.j) 阅读全文
posted @ 2023-05-28 16:11 Karlshell 阅读(12) 评论(0) 推荐(0)
摘要: package itheima; public class Test1 { //掌握懒汉式单例的写法 public static void main(String[] args) { B b1=B.getInstance();//第一次拿对象 B b2=B.getInstance(); System 阅读全文
posted @ 2023-05-28 15:54 Karlshell 阅读(14) 评论(0) 推荐(0)
摘要: package itheima; /*什么是设计模式,设计模式主要学什么?单例模式解决的什么问题? *设计模式就是具体问题的最优解决方案 * 确保一个类只有一个对象 * * 单例是什么?饿汉式单例特点是什么? * 把类的构造器私有;定义一个类变量储存类的一个对象;提供一个类方法返回对象 * 在获取类 阅读全文
posted @ 2023-05-28 15:43 Karlshell 阅读(8) 评论(0) 推荐(0)
摘要: package itheima; public class Test { public static void main(String[] args) { //认识两种代码块,了解他们的特点和基本作用 /**代码块是类的5大成分之一(成员变量、构造器、方法、代码块、内部类) * 静态代码块: * 格 阅读全文
posted @ 2023-05-28 15:22 Karlshell 阅读(45) 评论(0) 推荐(0)
摘要: package itheima; public class Test { public static void main(String[] args) { //掌握使用类方法、实例方法时的几点注意事项 //1.类方法中可以直接访问类的成员,不可以直接访问实例成员 //2.实例方法中既可以直接访问类成 阅读全文
posted @ 2023-05-28 14:51 Karlshell 阅读(21) 评论(0) 推荐(0)
摘要: package com.StaticDemo; public class Test2 { public static void main(String[] args) { //1.类方法的用法 //类名.类方法(推荐) Stndent1.printHelloWord(); //对象.类方法(不推荐) 阅读全文
posted @ 2023-05-28 14:29 Karlshell 阅读(101) 评论(0) 推荐(0)
摘要: package com.StaticDemo; public class Test1 { public static void main(String[] args) { //通过案列理解变量类型的应用场景 User u1 =new User(); User u2 =new User(); User 阅读全文
posted @ 2023-05-28 14:16 Karlshell 阅读(68) 评论(0) 推荐(0)
摘要: package com.StaticDemo; public class Student { //类变量也是静态变量 static String name; //实例变量 也叫对象变量 int age; } package com.StaticDemo; public class Test { pu 阅读全文
posted @ 2023-05-28 14:10 Karlshell 阅读(13) 评论(0) 推荐(0)
摘要: package com.variable; public class pkg { //1.同一个包下的程序,可以直接访问 //2.访问其他包下的程序,必须导包才可以访问 //3.自己的程序中调用Java提供的程序,也需要导包才可以使用,注意:Java.long包下的程序是不需要我们导包的,可以直接使 阅读全文
posted @ 2023-05-28 11:53 Karlshell 阅读(28) 评论(0) 推荐(0)
摘要: package com.variable; public class Test { //成员变量和局部变量的区别 //1.类中的位置不同:成员变量(类中,方法外)、局部变量(常见于方法中) //2.初始化值不同:成员变量(有默认值,不需要初始化赋值)、局部变量(没有默认值,使用之前必须完成赋值) / 阅读全文
posted @ 2023-05-28 11:53 Karlshell 阅读(35) 评论(0) 推荐(0)
摘要: package com.thisDemo; public class Student { double score; public void prinThis(){ System.out.println(this); } public void printPass(double score){ if 阅读全文
posted @ 2023-05-28 11:52 Karlshell 阅读(11) 评论(0) 推荐(0)
摘要: package com.thisDemo; //掌握this应用 //this有啥应用场景:主要用来解决变量名称冲突问题 public class thisDemo { public static void main(String[] args) { Student s1=new Student() 阅读全文
posted @ 2023-05-28 11:51 Karlshell 阅读(14) 评论(0) 推荐(0)