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>
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>
Share
Improve this question
asked Mar 5, 2014 at 1:59
user3346999user3346999
3
-
2
Cast the integer value to a
char
:(char) 83
yields'S'
. – rgettman Commented Mar 5, 2014 at 2:02 -
1
In Java Use
Character.toString((char)65)
which returnA
– ρяσѕρєя K Commented Mar 5, 2014 at 2:06 - possible duplicate of Creating Unicode character from its number – Merlevede Commented Mar 5, 2014 at 2:06
1 Answer
Reset to default 6You 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);