If you want to convert a String to CharSequence? Since String IS-A CharSequence, you can pass a String wherever you need a CharSequence, or assign a String to a CharSequence:
1 2 3 4 5 6 7 |
CharSequence cs = "string"; String s = cs.toString(); foo(s); // prints "string" public void foo(CharSequence cs) { System.out.println(cs); } |
If you want to convert a CharSequence to a String, just use the toString method that must be implemented by every concrete implementation of CharSequence.
Hope it helps.
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.