• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
 






cn-iwish

 
 

Powered by 博客园
博客园 | 首页 | 新随笔 | 联系 | 订阅 订阅 | 管理

03 2023 档案

 
集合没有指明泛型,获取数据需要强转
摘要:List list = new ArrayList(); list.add(2); list.add(1); list.remove(1); // 1 Iterator it = list.iterator(); //2 while(it.hasNext()){ // 3 int number = 阅读全文
posted @ 2023-03-06 19:38 残梦& 阅读(15) 评论(0) 推荐(0)
Object类对象的数字能参与四则运算吗
摘要:Object a = 1; System.out.println(a+1); 报错:The operator + is undefined for the argument type(s) Object, int 必须是基本数据类型(数值类型的)才能运算. 阅读全文
posted @ 2023-03-06 19:20 残梦& 阅读(19) 评论(0) 推荐(0)
map list 和set
摘要:List输出的顺序和输入的顺序一致,允许重复。 Set 输出的顺序和输入的顺序不一致,不允许有重复数据 List和Set继承Collection接口,所以增加方法是一样的add(),获取元素时,List可以有下标,普通for循环、增强for循环、迭代器三种方式。Set没有下标,所以有增强for循环、 阅读全文
posted @ 2023-03-05 16:58 残梦& 阅读(29) 评论(0) 推荐(0)
静态类和非静态类 抽象类
摘要:静态类和非静态类 静态类只能是内部类,外部类不能用static修饰,内部类可以使用static修饰。 创建方式: 外部类.静态内部类 对象名=外部类.new 静态内部类(); 外部类 对象名= new 外部类(); 外部类.非静态内部类 对象名1 = 对象名.new 非静态内部类(); 抽象类是否可 阅读全文
posted @ 2023-03-05 16:40 残梦& 阅读(73) 评论(0) 推荐(0)
类型转换异常ClassCastException
摘要:Person p = new Student(); //父引用指向子类 Student s=(Student)p //向下转型,可以 Teacher t = (Teacher)p; //p指向的是student,而不是teacher//此时报ClassCastException 其他常用异常:Ari 阅读全文
posted @ 2023-03-05 16:36 残梦& 阅读(37) 评论(0) 推荐(0)
字符串转换为基本数据类型
摘要:字符串转换为基本数据类型 Integer.parseInt();基本数据类型转为字符串String.valueOf(123);实例代码: String s = "1234"; System.out.println(Integer.parseInt(s));//1234 System.out.prin 阅读全文
posted @ 2023-03-05 16:16 残梦& 阅读(22) 评论(0) 推荐(0)