随笔分类 -  Java / Static

摘要:package itheima; public class Test { public static void main(String[] args) { //认识两种代码块,了解他们的特点和基本作用 /**代码块是类的5大成分之一(成员变量、构造器、方法、代码块、内部类) * 静态代码块: * 格 阅读全文
posted @ 2023-05-28 15:22 Karlshell 阅读(31) 评论(0) 推荐(0) 编辑
摘要:package itheima; public class Test { public static void main(String[] args) { //掌握使用类方法、实例方法时的几点注意事项 //1.类方法中可以直接访问类的成员,不可以直接访问实例成员 //2.实例方法中既可以直接访问类成 阅读全文
posted @ 2023-05-28 14:51 Karlshell 阅读(16) 评论(0) 推荐(0) 编辑
摘要:package com.StaticDemo; public class Test2 { public static void main(String[] args) { //1.类方法的用法 //类名.类方法(推荐) Stndent1.printHelloWord(); //对象.类方法(不推荐) 阅读全文
posted @ 2023-05-28 14:29 Karlshell 阅读(13) 评论(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 阅读(53) 评论(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 阅读(7) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示