Arrays Methods in Java code example
Example 1: Arrays in java
public class AccessingArrayElements
{
public static void main(String[] args)
{
int[] arrNum = {25, 23, 15, 20, 24};
for(int a = 0; a < arrNum.length; a++)
{
System.out.println(arrNum[a]);
}
}
}
Example 2: array methods in java
String[] aArray = new String[5];
String[] bArray = {"a","b","c", "d", "e"};
String[] cArray = new String[]{"a","b","c","d","e"};
Example 3: java Arrays method
int[] intArray = { 1, 2, 3, 4, 5 };
String intArrayString = Arrays.toString(intArray);
System.out.println(intArray);
System.out.println(intArrayString);
Example 4: two array structures in java
String[] MONTHS = {
"", "Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
};
...
System.out.println(MONTHS[m]);