以下代码有什么作用?可以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) 请考虑此代码段
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行的行有什么区别?