The toCharArray() in Java returns the Character Array and Arrays.toString() converts a array to string and toString() does same but why this below code doesn't work.
public static void main(String[] args) {
ArrayList<String> ar = new ArrayList<>(Arrays.asList( "abc", "def", "ghi", "jkl"));
char[] t = "abc".toCharArray();
String t2 = Arrays.toString(t);
if( ar.contains(t2)){
System.out.println("contains"); // This line doesn't get executed
}
String t3 = t.toString();
if( ar.contains(t3)){
System.out.println("contains"); // This line doesn't get executed
}
if( ar.contains("abc")){
System.out.println("contains"); // This line execute and prints on console
}
}