上一页 1 2 3 4 5 6 7 8 9 10 ··· 40 下一页
摘要: 后期使用反射的时候,如果自己重写了一个构造器,那么系统不会默认添加无参构造器, 建议在写类时,如果要添加有参构造方法,一定要将无参构造方法也加上 class Student{ // 构造方法 /** * 构造方法没有返回值,也没有void * 必须与类名一致 * 创建对象时调用 */ // publ 阅读全文
posted @ 2022-10-31 18:29 竹石2020 阅读(14) 评论(0) 推荐(0)
摘要: private修饰后,当前变量只能在当前的内中才能操作 // 定义一个学生类 class Student{ String name; private int score; public void setScore(int s){ if (s>=0 && s<=100){ score = s; }el 阅读全文
posted @ 2022-10-31 12:39 竹石2020 阅读(54) 评论(0) 推荐(0)
摘要: import java.util.Arrays; public class MaoPaoDemo { public static void main(String[] args) { int[] arr = {2,7,4,8,3,2,3,10,4}; // 循环9次 for (int i = 1;i 阅读全文
posted @ 2022-10-30 17:30 竹石2020 阅读(13) 评论(0) 推荐(0)
摘要: import java.util.Arrays; public class ArryFan2 { public static void main(String[] args) { int[] arr = {1,2,3,4,5}; for (int left = 0,right = arr.lengt 阅读全文
posted @ 2022-10-30 12:37 竹石2020 阅读(45) 评论(0) 推荐(0)
摘要: public class ArrayTwo { public static void main(String[] args) { int[][] arr = { {1,2,3}, {11,223,44} }; for (int i =0;i<arr.length;i++){ for (int j = 阅读全文
posted @ 2022-10-29 23:59 竹石2020 阅读(11) 评论(0) 推荐(0)
摘要: import java.util.Arrays; public class CopyDemo { public static void main(String[] args) { int[] arr = {10,20,30,40,50,60,70,80}; System.out.println("数 阅读全文
posted @ 2022-10-29 23:52 竹石2020 阅读(28) 评论(0) 推荐(0)
摘要: java中的函数必须放在类中。 void和return不能同时存在 java中,方法名可以相同,但是当方法名相同的时候,方法的参数不能一样。 这属于方法的重复 当方法的名字一样,参数不一样的时候就叫做方法的重载 阅读全文
posted @ 2022-10-29 22:33 竹石2020 阅读(16) 评论(0) 推荐(0)
摘要: package cn.tedu.type1; public class ForDemo { public static void main(String[] args) { outer: for (int j = 1;j<10;j++){ for (int i =0;i<10;i++){ Syste 阅读全文
posted @ 2022-10-29 13:27 竹石2020 阅读(7) 评论(0) 推荐(0)
摘要: Random的包先生成实例 Random rm = new Random(); new Random().nextInt(); -- 返回int范围内的一个随 机整数 new Random().nextInt( n ); -- 返回0~n之间的一个随 机整数,包括0但不包括n new Random( 阅读全文
posted @ 2022-10-28 13:07 竹石2020 阅读(18) 评论(0) 推荐(0)
摘要: 基本数据类型 类型 占用空 间 范围 byte 1字节 -2^7 到 2^7-1,即 -128~127 short 2字节 -2^15 到 2^15-1,即 -32768~32767 int(默认) 4字节 -2^31 到 2^31-1,即 -2147483648~2147483647(21.47亿 阅读全文
posted @ 2022-10-27 22:32 竹石2020 阅读(35) 评论(0) 推荐(0)
上一页 1 2 3 4 5 6 7 8 9 10 ··· 40 下一页