admin管理员组文章数量:1336614
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);
本文标签: Is there a Java equivalent of the Javascript method fromCharCode()Stack Overflow
版权声明:本文标题:Is there a Java equivalent of the Javascript method fromCharCode()? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742409424a2469487.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论