I want to change the char data type to String. How do I do it
string java type-conversion
Write Character.toString(char).
Or
1. String stringValueOf = String.valueOf('c'); // most efficient
2. String stringValueOfCharArray = String.valueOf(new char[]{x});
3. String characterToString = Character.toString('c');
4. String characterObjectToString = new Character('c').toString();
// // Although this method seems very simple,
// // this is less efficient because the concatenation
// // expands to new StringBuilder().append(x).append("").toString();
5. String concatBlankString = 'c' + "";
6. String fromCharArray = new String(new char[]{x});
There's a way like this.
© 2024 OneMinuteCode. All rights reserved.