1. Program
How to find out size of an array ?
class G { public static void main(String[] args) { String[] a = new String[15]; System.out.println(a.length); } }
2. Program
How to print element of an array ?
class H { public static void main(String[] args) { int[] a = new int[10]; for(int i = 0 ; i < a.length ; i++) { System.out.println(a[i]); } } }
3. Program
How to assign index itself as an array elements ?
class I { public static void main(String[] args) { int[] a = new int[10]; for(int i = 0 ; i < a.length ; i++) { a[i] = i ; } for(int i = 0 ; i < a.length ; i++) { System.out.print( a[i] + ", "); } } }
4. Program
//How to assign an initial values to an array while defining an array?
class K { public static void main(String[] args) { int[] a = {2, 34, 4, 16, 77, 1, 8}; for(int i = 0; i < a.length ; i++) { System.out.print( a[i] + ", "); } } }
