zoukankan      html  css  js  c++  java
  • 软件构造雨课堂知识点总结(一)

    0-1 试试Java
    第一题
    Integer a = new Integer(3);
    Integer b = 3;
    int c = 3;
    System.out.println(a == b);
    System.out.println(a == c);
    控制台输出结果是:
    False;True
    解析:
    针对第四行,a和b是两个不同的object, 在heap中指向不同的地址,“==”判 定对象等价性(将在3.5节继续讨论)。
    这对第五行,a作为一个Integer对象, 将会首先被auto-unboxing为一个int, 然后再跟c比较。针对int类型的==,比 较的是值。

    第二题
    String a = “c”;
    String b = “c”;
    System.out.println("a and b: " + a == b);
    控制台的输出结果是:
    False
    解析:
    +的优先级比==要高,先计算两个字符串+,然后再跟b比较。

    第三题
    public static void main(String args[]){
    System.out.println(2.00 - 1.10);
    }
    控制台输出结果是:
    0.8999999999999999

    第四题
    List<Integer> list = new ArrayList<>();
    for(int i = -3; i < 3; i++)
    list.add(i);
    for(int i = 0; i < 3; i++)
    list.remove(i);
    System.out.println(list);
    解析:
    [-2, 0, 2]

    第五题
    String s = " Hello";
    s += " world ";
    s.trim();
    System.out.println(s);
    解析:
    " Hello World "

  • 相关阅读:
    转:Spark User Defined Aggregate Function (UDAF) using Java
    同步类容器和并发类容器
    线程间通信
    线程安全
    浅入tomcat
    PLSQL操作excel
    Eclipse中使用Maven创建web项目
    PLSQL数据库操作(excel)
    Python学习-列表深浅拷贝
    Python学习-列表元组字典操作
  • 原文地址:https://www.cnblogs.com/HIT-ryp/p/10511568.html
Copyright © 2011-2022 走看看