Search Interview Questions | Click here and help us by providing the answer. Click Correct / Improve and please let us know. |
|
|||
|
| ||||
| Core Java - Interview Questions and Answers for 'Char to string' - 2 question(s) found - Order By Rating | ||||
| ||||
| Ans. String has an argument constructor that take char array as argument and creates a string. There is no constructor available with String that takes in a character and creates a String. We can use StringBuilder which has a char argument constructor. | ||||
| ||||
| Ans. We can use StringBuilder. StringBuilder accepts char as the argument for it's constructor. new StringBuilder('').toString(); | ||||
System.out.println((int)'a'); | ||||
System.out.println((Integer)'a'); | ||||