我有一个问题,我需要采取一个字符数组(仅由数字组成)并将其值作为整数打印出来.
public static int ParseInt(char [] c) {
//convert to an int
return int;
}
Run Code Online (Sandbox Code Playgroud)
该数组看起来像这样:
char [] c = {'3', '5', '9', '3'}
Run Code Online (Sandbox Code Playgroud)
并会给出一个输出:
3593
Run Code Online (Sandbox Code Playgroud)
我该怎么做呢?
char[] c = {'3', '5', '9', '3'};
int number = Integer.parseInt(new String(c));
Run Code Online (Sandbox Code Playgroud)