Java Arrays Programming Examples How to declare an array in Java? How to Code Example to print array values in Java Store value in Array and how to print value in array in java code
public class ArraysExample {
public static void main(String[] args) {
//Arrays Declaration
int[] firstArray;
firstArray = new int[3];
int[] secondArray = new int[10];
//Store value in Arrays
for(int i = 0; i < firstArray.length; i++){
firstArray[i] = i;
}
//Print value in Arrays
System.out.println("firstArray contents");
for(int i = 0; i < firstArray.length; i++) {
System.out.println(firstArray[i] + " " );
}
}
}
0 comments:
Post a Comment