Converting String Array to Integer Array Example Java

Converting String Array to Integer Array Example Java

Java Program to Convert String Array to Integer Array:
In this below program we have converted string array to integer array.

package in.javadomain;

public class StringArrayToIntArray {
	public static void main(String[] args) {
		String[] strArray = { "10", "20", "30", "40", "50" };
		int[] intArray = new int[strArray.length];
		for (int i = 0; i < strArray.length; i++) {
			intArray[i] = Integer.parseInt(strArray[i]);
		}

		for (int i = 0; i < intArray.length; i++) {
			System.out.println("Integer Array Values ::  " + intArray[i]);
		}
	}

}

Output:
[plain gutter=”false”]
Integer Array Values :: 10
Integer Array Values :: 20
Integer Array Values :: 30
Integer Array Values :: 40
Integer Array Values :: 50
[/plain]

Recommended Java Books:

1,286 total views, 2 views today

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.