5

Although I do understand that javascript and Java are very different programming languages, I like the method fromCharCode () with which I can convert a unicode character like 65 to A etc. Is there a method within Java which will allow me to do the same?

Example of use fromCharCode() in javascript:

<button onclick="myFunction()">Try it</button>

<script>
function myFunction()
{
var res = String.fromCharCode(83);
document.getElementById("demo").innerHTML=res;
}
</script>

1 Answers1

6

You can cast the integer to char

int i = 83;
char c = (char)83;

if you want to get the string:

String s = Character.toString(c);
Hessam
  • 1,377
  • 1
  • 23
  • 45