import java.util.Arrays;

class Feb8 {

	public static void main(String[] args) {

		int i = 0;
		while(i < 10) {
			System.out.print(i + " ");
			i++;
		}
		System.out.println();

		for(i = 0; i < 10; i++) {
			System.out.print(i + " ");
		}
		System.out.println();

		// the array is the fundamental container

		// the general form of an array is ...

		// type[] array-name = new type[num-elements];

		// define an array of integers that can hold 10 integers.

		int[] array1= new int[10];

		int size = 7;

		int[] array2 = new int[size];

		// cannot modify the length of an array after its created

		// all elements in an array have a defined index value.

		// array     [ 1, 3, 5, 7, 9]
		// indices     0  1  2  3  4

		// length of the array is 5
		// so valid indices are 0 -> 4  or 0 -> (length-1)

		// we store elements in an array as follows

		array1[0] = 1;
		array1[1] = 3;
		array1[2] = 5;
		array1[3] = 7;
		array1[4] = 9;
		
		int age = array1[1];  // what value is in age?  ans: 3

		int len = array1.length;  // what value is in len? ans: 10

		// default value of elements in int arrays is 0
		System.out.println(array1[5]);	// prints 0

		for(i = 0; i < array1.length; i++) {
			System.out.print(array1[i] + " ");
		}
		System.out.println();

		// set all values to 7

		for(i = 0; i < array1.length; i++) {
			array1[i] = 7;
		}	

		for(i = 0; i < array1.length; i++) {
			System.out.print(array1[i] + " ");
		}
		System.out.println();

		// you can initialize an array when you declare the array

		int[] array3 = {2, 4, 1, 8, 10};

		for(i = 0; i < array3.length; i++) {
			System.out.print(array3[i] + " ");
		}
		System.out.println();

		// find smallest value in array3
			
		int smallest = array3[0];
		for(i = 1; i < array3.length; i++) {
			if (array3[i] < smallest) {
				smallest = array3[i];
			}
		}
		System.out.println("smallest: " + smallest);	


		// fill using Arrays.fill
	
		Arrays.fill(array3, -1);
		
		for(i = 0; i < array3.length; i++) {
			System.out.print(array3[i] + " ");
		}
		System.out.println();

		
	}
} // End of class










