随笔分类 -  JAVA入门

摘要:arr字符串转int数组arrint arrint[i] = Integer.parseInt(arr[i]); int数组转换为StringBuilder StringBuilder sarr = new StringBuilder(); for(int i = 0 ;i<arrint.lengt 阅读全文

posted @ 2022-05-28 11:04 LutixiaGit 阅读(25) 评论(0) 推荐(0) 编辑

摘要:Animal a1 = new Cat() 多态的前提和体现: 有继承/实现关系 有方法重写 有父类指向子类对象 多态中成员的访问特点: 成员变量: 编译看左边,运行看左边 成员方法 :编译看左边,执行看右边 多态的优点和缺点: 缺点:不能访问子类特有功能 优点:提高了程序的扩展性 阅读全文

posted @ 2022-05-24 22:51 LutixiaGit 阅读(21) 评论(0) 推荐(0) 编辑

摘要:动物类的设计 package Animals; public class Animal { private String name; private String age; public Animal() { System.out.println("动物"); } public Animal(Str 阅读全文

posted @ 2022-05-24 21:25 LutixiaGit 阅读(58) 评论(0) 推荐(0) 编辑

摘要:1.使用方法: 子类定义时添加: public class ZI extend FU{ } 父类: package FUandZI; public class FU { public void fushow(){ System.out.println("FUshow"); } } 子类: packa 阅读全文

posted @ 2022-05-23 11:07 LutixiaGit 阅读(122) 评论(0) 推荐(0) 编辑

摘要:要点: 类的创建与赋值 ArrayList保存类的内容 遍历/查找/删除类中的数据 类的创建 package CAK1; public class Student { private String name; private String age; private String sno; publi 阅读全文

posted @ 2022-05-23 10:46 LutixiaGit 阅读(98) 评论(0) 推荐(0) 编辑

摘要:需求:键盘录入一个字符串,使用程序实现在控制台遍历该字符串思路:键盘录入一个字符串,用Scanner实现②遍历字符串,首先要能够获取到字符串中的每一个字符 public char charAt(int index):返回指定索引处的char值,字符串的索引也是从O开始的③遍历字符串,其次要能够获取到 阅读全文

posted @ 2022-05-22 11:33 LutixiaGit 阅读(226) 评论(0) 推荐(0) 编辑

摘要:要求: 需求:已知用户名和密码,请用程序实现模拟用户登录。总共给三次机会,登录之后,给出相应的提示思路:已知用户名和密码,定义两个字符串表示即可②键盘录入要登录的用户名和密码,用Scanner实现③拿键盘录入的用户名、密码和已知的用户名、密码进行比较,给出相应的提示。字符串的内容比较,用equals 阅读全文

posted @ 2022-05-21 23:25 LutixiaGit 阅读(60) 评论(0) 推荐(0) 编辑

摘要:String类代表字符串,使用不需要导包 字符串的值创建后不可以修改 package API; import java.util.Scanner; public class ranDom { public static void main(String[] args) { // Scanner sc 阅读全文

posted @ 2022-05-21 22:48 LutixiaGit 阅读(18) 评论(0) 推荐(0) 编辑

摘要:package CAK1; public class Student { private String name; private int age; public Student(){ System.out.println("无参构造方法"); } public void show(){ Syste 阅读全文

posted @ 2022-05-19 23:42 LutixiaGit 阅读(72) 评论(0) 推荐(0) 编辑

摘要:封装:将类的某些信息隐藏在类内部,不允许外介直接访问,用private创建,使用get / set 方法访问。 好处:提高了安全性,提高了代码的复用性。 阅读全文

posted @ 2022-05-19 23:35 LutixiaGit 阅读(28) 评论(0) 推荐(0) 编辑

摘要:package CAK; public class Student { private String name; int age; private int sno; public void setSno(int Sno){ if(sno <= 0 ){ System.out.println("wro 阅读全文

posted @ 2022-05-19 23:32 LutixiaGit 阅读(30) 评论(0) 推荐(0) 编辑

摘要:提供了set和get方法 private 变量不能直接访问,需要在类内定义函数访问,可以用于保护变量,检测变量输入等等 定义Student类,其中sno为私有变量 package CAK; public class Student { String name; int age; private in 阅读全文

posted @ 2022-05-19 23:19 LutixiaGit 阅读(61) 评论(0) 推荐(0) 编辑

摘要:对象:万物皆对象。 面向对象:关注的某个事物信息。 类:是对象的数据类型,具有相同属性和行为的一组对象的集合。 对象的属性:对象具有的各种特征 对象的行为:独享能够执行的操作 类和对象 的关系: 类 定义类 //默认值为null 和 0 public class Student { String n 阅读全文

posted @ 2022-05-18 18:23 LutixiaGit 阅读(25) 评论(0) 推荐(0) 编辑

摘要:import java.util.Scanner; public class Score { public static void main(String[] args) { System.out.println("请输入评委个数"); Scanner sc = new Scanner(System 阅读全文

posted @ 2022-05-18 17:06 LutixiaGit 阅读(52) 评论(0) 推荐(0) 编辑

摘要:public class Method { public static void main(String[] args) { int[] arr = {11,22,1,2,33,4}; System.out.println(getMax(arr)); } public static int getM 阅读全文

posted @ 2022-05-18 11:12 LutixiaGit 阅读(34) 评论(0) 推荐(0) 编辑

摘要:System.out.println(cmp(5,10)); System.out.println(cmp((short)5,(short)10)); public static boolean cmp(int a,int b){ return a == b; } public static boo 阅读全文

posted @ 2022-05-17 13:18 LutixiaGit 阅读(13) 评论(0) 推荐(0) 编辑

摘要:形参:方法中定义的参数(int num) 实参:方法中调用的参数 (10) public class Find_word { public static void main(String[] args){ isNumber(10); int number = 11; isNumber(number) 阅读全文

posted @ 2022-05-17 13:07 LutixiaGit 阅读(47) 评论(0) 推荐(0) 编辑

摘要:数组个数:arr.lenth for(int i = 0 ;i<arr.length;i++){ System.out.println(arr[i]); } 数组遍历。 阅读全文

posted @ 2022-05-17 00:29 LutixiaGit 阅读(15) 评论(0) 推荐(0) 编辑

摘要:package CAK; public class AK { public static void main(String[] args) { int[] arr = new int[3]; System.out.println(arr);//内存地址 System.out.println(arr[ 阅读全文

posted @ 2022-05-17 00:12 LutixiaGit 阅读(55) 评论(0) 推荐(0) 编辑

摘要: 阅读全文

posted @ 2022-05-16 15:51 LutixiaGit 阅读(6) 评论(0) 推荐(0) 编辑

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