Java Arrays

import java.util.Arrays; class Test { public static void main(String[] args) { String[] names = {“John”, “Steve”, “Melissa”, “Maria”}; System.out.println(Arrays.toString(names)); } } Output: [John, Steve, Melissa, Maria]   copyOf(type [] a, int n) Returns a new copy of the array, which consists of the first n of its elements. import java.util.Arrays; class Test { public static…

Read More Arrays class in Java

class Test { int[] a; int b[]; int []c; } class Test { int[] a = new int[100]; int b[] = new int[]{1, 2, 3}; int[] c = {1, 2, 3}; } class Test { public static void main(String[] args) { // initialize the array int[] a = new int[3]; // add elements to array…

Read More Java Arrays