java – 如何将char []转换为int?
发布时间:2020-12-15 04:25:20 所属栏目:Java 来源:网络整理
导读:我有一个问题,我需要采取一个字符数组(仅由数字组成)并将其值作为整数打印出来. public static int ParseInt(char [] c) { //convert to an int return int;} 该数组看起来像这样: char [] c = {'3','5','9','3'} 并会给出一个输出: 3593 我该怎么做呢?
我有一个问题,我需要采取一个字符数组(仅由数字组成)并将其值作为整数打印出来.
public static int ParseInt(char [] c) { //convert to an int return int; } 该数组看起来像这样: char [] c = {'3','5','9','3'} 并会给出一个输出: 3593 我该怎么做呢? 解决方法char[] c = {'3','3'}; int number = Integer.parseInt(new String(c)); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |