siyuliu  

2025年11月11日

摘要: instanceof(检测左侧的对象是否为右侧类或接口的实例) public class Main { public static void main(String[] args) { //方法的调用只和左边定义的数据类型有关 Object object=new teacher(); System. 阅读全文
posted @ 2025-11-11 21:21 nnnnnnunn 阅读(5) 评论(0) 推荐(0)
 
摘要: main public class Main { public static void main(String[] args) { //方法的调用只和左边定义的数据类型有关 stu s=new teacher(); s.say();//stu,如果不加static,子类重写父类的方法输出teache 阅读全文
posted @ 2025-11-11 19:20 nnnnnnunn 阅读(5) 评论(0) 推荐(0)
 
摘要: 子类: public class teacher extends stu{ } 父类 public class stu { public String name="111"; public void say() { System.out.println("shuohua"); } } 使用 publ 阅读全文
posted @ 2025-11-11 18:54 nnnnnnunn 阅读(5) 评论(0) 推荐(0)
 
摘要: 属性私有,可在类内自定义public函数得到或者修改私有属性(alt+insert快速生成函数) class stu { private String name; public String getName() { return name; } public void setName(String 阅读全文
posted @ 2025-11-11 14:40 nnnnnnunn 阅读(5) 评论(0) 推荐(0)
 
摘要: 有参和无参 package org.example; import java.util.Arrays; public class Main { public static void main(String[] args) { stu stu1=new stu("n"); System.out.pri 阅读全文
posted @ 2025-11-11 11:58 nnnnnnunn 阅读(5) 评论(0) 推荐(0)
 
摘要: package org.example; import java.util.Arrays; public class Main { public static void main(String[] args) { stu stu1=new stu(); stu1.say(); change(stu1 阅读全文
posted @ 2025-11-11 11:54 nnnnnnunn 阅读(4) 评论(0) 推荐(0)
 
摘要: 有static public class Main { public static void main(String[] args) { say(); } public static void say() { System.out.println("xuesheng"); } } 没有static 阅读全文
posted @ 2025-11-11 10:28 nnnnnnunn 阅读(3) 评论(0) 推荐(0)

2025年11月10日

摘要: array的tostring和sort和fill package org.example; import java.util.Arrays; public class Main { public static void main(String[] args) { int[][] nums= new 阅读全文
posted @ 2025-11-10 17:26 nnnnnnunn 阅读(10) 评论(0) 推荐(0)
 
摘要: package org.example; public class Main { public static void main(String[] args) { int[] nums;//数组定义 nums = new int[10];//可以存放10个数字 for (int i = 0; i < 阅读全文
posted @ 2025-11-10 15:35 nnnnnnunn 阅读(8) 评论(0) 推荐(0)

2025年11月9日

摘要: package org.example; public class Main { public static void main(String[] args) { Main s=new Main(); s.test(1,2); s.test(); } public void test(int...i 阅读全文
posted @ 2025-11-09 22:16 nnnnnnunn 阅读(5) 评论(0) 推荐(0)