askIT

Array

Integer

Use int[] to create arrays of the type int.

int[] myIntArray = new int[3];
int[] myIntArray = {1,2,3};
int[] myIntArray = new int[]{1,2,3};

String

Use String[] to declare an array of strings.

String[] myStringArray = new String[3];
String[] myStringArray = {"a","b","c"};
String[] myStringArray = new String[]{"a","b","c"};

You can also declare the array with String[] and then assign values to it later.

String[] myStringArray;
myStringArray = new String[]{"a","b","c"};

Add comment

avatar_blank_60.png

Comment:

Name:

Email:

Comments

No comments yet. You can be the first one to comment. Just write your comment in the form and click on the submit button.