How does CharSequence change to String?

Asked 2 years ago, Updated 2 years ago, 106 views

How does CharSequence change to String?

character java string

2022-09-22 16:14

1 Answers

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));


2022-09-22 16:14

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.