小编sam*_*sam的帖子

可以用HashSet替换此代码中的LinkedHashSet吗?

以下代码有什么作用?可以LinkedHashSet换成HashSet

public class CollectionFunction {
    public <E> List<E> function(List<E> list) {
        return new ArrayList<E>(new LinkedHashSet<E>(list));
    }
}
Run Code Online (Sandbox Code Playgroud)

java data-structures

3
推荐指数
1
解决办法
340
查看次数

乘法最终和非最终的int变量有什么区别?

请考虑此代码段

public class ConstantFolding {

   static final  int number1 = 5;
   static final  int number2 = 6;

   static int number3 = 5;
   static int number4 = 6;

   public static void main(String[ ] args) {
      int product1 = number1 * number2;             //line A
      int product2 = number3 * number4;             //line B
   }
}
Run Code Online (Sandbox Code Playgroud)

标记为A行的行与标记为B行的行有什么区别?

java

1
推荐指数
1
解决办法
180
查看次数

标签 统计

java ×2

data-structures ×1