Java char数组为int [英] Java char array to int
本文介绍了Java char数组为int的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以将包含数字的 char []
数组转换为
和 int
?
Is it possible to convert a char[]
array containing numbers into
an int
?
推荐答案
char []
是否包含组成数字的unicode字符这个数字?在这种情况下,只需从 char []
创建一个String并使用Integer.parseInt:
Does the char[]
contain the unicode characters making up the digits of the number? In that case simply create a String from the char[]
and use Integer.parseInt:
char[] digits = { '1', '2', '3' };
int number = Integer.parseInt(new String(digits));
这篇关于Java char数组为int的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文