6

Here I want to convert sting array values into integer array,Need to store all string values into integer array, Here is the string array:

private String[] aa = {"70","80","99","140","150","199","200","300",
                       "349","350","400","499","500","501","900","1000","1100","1200"};
2

3 Answers 3

3

If you're on Java8, you could do:

int[] array = Stream.of(aa).mapToInt(Integer::parseInt).toArray();
Sign up to request clarification or add additional context in comments.

Comments

1

Loop through the array and convert it to int.

int []intArray = new int[strArray.length];
int i = 0;
for(String s : strArray)
  intArray[i ++] = Integer.parseInt(s);
System.out.println(Arrays.toString(intArray));

Comments

1
    int[] bb = new int[aa.length];
    for (int i = 0; i < aa.length; i++) {
        bb[i] = Integer.parseInt(aa[i]);
    }

http://ideone.com/uJCAX2

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.