Preview:
//Arrays (One-Dimensional):
/*
An array is a Container object that holds a fixed 
number of values of a single data type.
*/
public class MedoClass {
    public static void main(String[] args) {
        int []num=new int[5];
        num[0]=15;
        System.out.print(num[0]);
    }
}
public class Amazon {
    public static void main(String[] args) {
        int[] num = new int[5];
        num[0] = 10;
        num[1] = 30;
        System.out.println(num[1]);
    }
}
public class Amazon {
    public static void main(String[] args) {
        int[] num = new int[5];
        num[0] = 10;
        num[1] = 20;
        num[2] = 30;
        num[3] = 40;
        num[4] = 50;
        System.out.println(num[4]);
    }
}
public class Amazon {
    public static void main(String[] args) {
        int[] num = new int[5];//take from zero to four.
        num[0] = 10;
        num[1] = 20;
        num[2] = 30;
        num[3] = 40;
        num[4] = 50;
        num[5] = 60;//Error 
        System.out.println(num[5]);//Error
    }
}
public class Amazon {
    public static void main(String[] args) {
        int num[] = new int[5];
        num[0] = 10;
        num[1] = 20;
        num[2] = 30;
        num[3] = 40;
        num[4] = 50;
        num[5] = 60;
        System.out.println(num[5]);
    }
}
public class Amazon {
    public static void main(String[] args) {
        int num[]; 
        num=new int[5];
        num[0] = 10;
        num[1] = 20;
        num[2] = 30;
        num[3] = 40;
        num[4] = 50;
        num[5] = 60;
        System.out.println(num[5]);
    }
}
public class Amazon {
    public static void main(String[] args) {
        int num[] = { 1, 8, 9, 5 };
        System.out.println(num[0] + " " + num[1]);
    }
}
public class Amazon {
    public static void main(String[] args) {
        int num[] = { 1, 8, 9, 5 };
        num[0] = 55;
        System.out.println(num[0] + " " + num[1]);
    }
}
public class Amazon {
    public static void main(String[] args) {
        int num[] = { 1, 8, 9, 5 };
        num[7] = 55;//error size equal 4
        System.out.println(num[0] + " " + num[1]);
    }
}
public class Amazon {
    public static void main(String[] args) {
        int num[] = { 1, 8, 9, 5 };
        System.out.println(num.length);
    }
}
public class Amazon {
    public static void main(String[] args) {
        double arr[] = new int[6];//Error
        System.out.println();
    }
}
public class Amazon {
    public static void main(String[] args) {
        double arr[] = new double[6];
        System.out.println(arr[0]);
    }
}
public class Amazon {
    public static void main(String[] args) {
        double arr[] = new double[6];
        System.out.println(arr[0]);
    }
}
public class Amazon {
    public static void main(String[] args) {
        boolean arr[] = new boolean[6];
        System.out.println(arr[1]);//false default
    }
}
public class Amazon {
    public static void main(String[] args) {
        char[] arr = new char[6];
        System.out.println(arr[1]);//Null means having no value
    }
}
public class Amazon {
    public static void main(String[] args) {
        char[] arr = new char[6];
        arr[0] = 'a';
        arr[1] = 'b';
        arr[2] = 'c';
        arr[3] = 'd';
        arr[4] = 'e';
        arr[5] = 'f';
        System.out.println(arr[1]);
    }
}
public class Amazon {
    public static void main(String[] args) {
        String arr[] = new String[6];
        System.out.println(arr[0]);//null
    }
}
public class Amazon {
    public static void main(String[] args) {
        String arr1[] = new String[] { "Ali", "Ahmed", "Belal" };
        System.out.println(arr1[0]);
    }
}
public class Amazon {
    public static void main(String[] args) {
        String arr1[] = { "Ali", "Ahmed", "Belal" };
        System.out.println(arr1[0]);
    }
}
public class Amazon {
    public static void main(String[] args) {
        String arr[] = new String[] { "Ali", "Ahmed", "Belal" };
        System.out.println(arr[0]);
        System.out.println(arr[1]);
        System.out.println(arr[2]);
    }
}
public class Amazon {
    public static void main(String[] args) {
        String arr[] = new String[] { "Ali", "Ahmed", "Belal" };
        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i]);
        }
    }
}
public class Amazon {
    public static void main(String[] args) {
        String arr[] = new String[] { "Ali", "Ahmed", "Belal" };
        for (int i = 0; i < arr.length; i++) {//i must = 1.
            System.out.println(arr[i]);
        }
    }
}
public class Amazon {
    public static void main(String[] args) {
        String arr[] = new String[] { "Ali", "Ahmed", "Belal" };
        for (String i : arr) {
            System.out.println(i);
        }
    }
}
public class Amazon {
    public static void main(String[] args) {
        String arr[] = new String[] { "Ali", "Ahmed", "Belal" };
        for (String i : arr) {
            System.out.println(i);
        }
    }
}
public class Amazon {
    public static void main(String[] args) {
        int size=15;
        int  arr[]=new int[size];
    }
}
public class Amazon {
    public static void main(String[] args) {
        short size = 15;//not double jast size.
        int arr[] = new int[size];
    }
}
public class Amazon {
    public static void main(String[] args) {
        short size = 15;
        int arr[] = new int[size];
        arr[0]=15;
        System.out.println(arr[0]);
    }
}
import java.util.Scanner;
import jdk.tools.jlink.resources.plugins;
public class Amazon {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        short size = input.nextShort();
        int[] arr = new int[size];
        for (short i = 0; i < arr.length; i++) {
            arr[i] = input.nextInt();
        }
        System.out.print("[");
        for (int i : arr) {
            System.out.print(i + ",");
        }
        System.out.print("]");
    }
}











downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter