String Reference Equality in an ArrayList
What is the output of the above program?
import java.util.ArrayList;
public class Test {
public static void main(String[] args) {
ArrayList<String> list = new ArrayList<>();
list.add("Hello");
list.add(new String("Hello"));
System.out.println(list.get(0) == list.get(1));
}
}
A
Runtime Error
B
Compilation Error
C
true
D
false
APFIVE