Java – how to convert char [] to int?

I have a problem. I need to take an array of characters (only composed of numbers) and print its value as an integer

public static int ParseInt(char [] c) {
    //convert to an int
    return int;
}

The array looks like this:

char [] c = {'3','5','9','3'}

And an output will be given:

3593

What should I do?

Solution

char[] c = {'3','3'};
char[] c = {'3','3'};
int number = Integer.parseInt(new String(c));
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>