The 'new' keyword always creates a new object.
Therefore, in both cases 1 and 2, the references s and s1 denote separate objects.
Given the hashcode is based on value, in both cases, the same hashcode is getting generated for each of s and s1.
Code as below:
// CASE 1
String s=new String("ll");
String s1=new String(s);
System.out.println(s.hashCode()); //prints 3456
System.out.println(s1.hashCode()); //prints 3456
// CASE 2
String ss=new String("ll");
String ss1=new String("ll");
System.out.println(ss.hashCode()); //prints 3456
System.out.println(ss1.hashCode()); //also prints 3456