You can use the toString method.
String s = "a string";
CharSequence cs = new StringBuffer("a string");
String s2 = cs.toString();
System.out.println("s.equals(s2): " + s.equals(s2));
System.out.println("s == s2: " + (s == s2));
© 2024 OneMinuteCode. All rights reserved.