Array Implementation
CustomArray.java

package com.mugil.alg;

public class CustomArray {
	private int[] arrNum = new int[50];
	private int arrSize = 10;
	
	public static void main(String[] args) {
		CustomArray objCustomArray = new CustomArray();
		System.out.println("---------------");
		System.out.println("Array Initialized");
		objCustomArray.initializeArray();
		objCustomArray.printArray();
		
		System.out.println("---------------");
		System.out.println("Search for No(Index) - " + objCustomArray.getNumIndex(8));
		
		System.out.println("---------------");
		System.out.println("Delete Called");
		objCustomArray.deleteArrayByIndex(5);		
		objCustomArray.printArray();
		
		
		System.out.println("---------------");
		System.out.println("Insert Called");
		objCustomArray.insertArray(20);		
		objCustomArray.printArray();
		
		
	}
	
	public void initializeArray()
	{	
		for (int i = 0; i < arrSize; i++) {
			arrNum[i]  = (int)(Math.random()*10); 
		}
	}
	
	public void printArray()
	{
		
		System.out.print("Array - ");
		for (int i = 0; i < getArraySize(); i++) {
			System.out.print(arrNum[i]);
			System.out.print(" ");
		}		
		System.out.println();
	}
	
	
	//Linear Search
	//Use this if you want to find all the
	//all the places where the element Occurs
	public String getNumIndex(int pNum)
	{
		String NumPOS = "";
		
		for (int i = 0; i < getArraySize(); i++) {
			if(pNum == arrNum[i])
			{
				NumPOS +=  i + " ";
			}
		}
		
		if(NumPOS == "")
		 NumPOS = "None";
		
		return NumPOS;
	}
	
	
	public int getArraySize()
	{
		return arrSize;
	}
	
	public void deleteArrayByIndex(int pPOS)
	{
		
		for (int i = pPOS; i < getArraySize(); i++) {
				arrNum[i] = arrNum[i+1]; 
		}
		
		arrSize--;
	}
	
	public void insertArray(int pNum)
	{
		arrNum[arrSize] = pNum;		
		arrSize++;	
	}
}

Two Dimensional Arrays (Array of Arrays)

 //Seating Arrangement for 20 Seats
 int arrSeating[][] = new int[4][5];

 //No of Items Produced in Hr By Days in Month
 int arrProdHrByDaysInMonth[][] = new int[30][24];

Two Dimensional Arrays(Array of Arrays of Arrays)

 //No of Items Produced in Hr By Days in Month by Month
 int arrProdHrByDaysInMonth[][][] = new int[12][30][24];

Jagged Arrays
array of arrays such that member arrays can be of different sizes

Looping through ArrayList

         	//Iterate over Collection
		for (Iterator iterator = arrNames.iterator(); iterator.hasNext();) {
			String object = (String) iterator.next();
			System.out.println(object);
		}			
		
		//Iterate over array or Collection
		for (String string : arrNames) {
			System.out.println(string);
		}		
		
		//Iterate over array 
		for (int i = 0; i < arrNames.size(); i++) {
			System.out.println(arrNames.get(i));
		}
		
		//Iterate over array using Temporary Variable
		for (int i = 0; i < arrNames.size(); i++) {
			String string = arrNames.get(i);
			System.out.println(string);
		}

Which one of the Above method is Faster?
All the methods are of same speed since the Traditional for loop uses Iterator inside.The performance difference is noted when there is change in data structure while doing random access like linkedlist is slower than arraylist when you use a traditional for loop since to traverse a 6th element in list it should start from all again

When there is a sorted Array and you should do a search in the sorted array then using BinarySearch is faster than Linear Search

public static String[] removeElements(String[] input, String deleteMe) 
{
    List result = new LinkedList();

    for(String item : input)
        if(!deleteMe.equals(item))
            result.add(item);

    return result.toArray(input);
}

How to remove last element in a array and store it in same Array

 
import java.util.Arrays;

public class SimpleArray 
{
  public static void main(String[] args) 
  {
    String[] arrNames1 = {"Mugil", "Mani", "Vinu", "Shivaji", "Raman"};
    String[] arrNames2 = new String[arrNames1.length-1]; 
		
    for(int i=0;i<arrNames1.length-1;i++)
      arrNames2[i] = arrNames1[i];
		
    arrNames1 = arrNames2.clone();
		
    for (int i = 0; i < arrNames1.length; i++) 
      System.out.println(arrNames1[i]);		
  }
}
package com.apryll.package2;

public class sample2 
{
  public static void main(String args[])  
  {
    sample2 objsample2 = new sample2();
    objsample2.argCount(1, 2, 3, 4);
  }
	
  public void argCount(int num1, int num2, int... args)
  {
    System.out.println(num1);
    System.out.println(num2);
    System.out.println(args.length);
  }
}

OP
1
2
2

Please Note the Last 2 which accounts for the array argument args as num1 and num2 does not account for array arguments

If the Code is like below then it would have been a error

  public void argCount(int num1, int num2, int... args)

How to Loop Through Arguments Passed to function

package com.apryll.package2;

public class sample2 
{
 public static void main(String args[])  
 {
  sample2 objsample2 = new sample2();
  objsample2.argCount(1, 2, 3, 4);
 }
	
 public void argCount(int... args)
 {
   System.out.println(args.length);
 }
}

How to find Length of Array

public class Main 
{
  public static void main(String args[])
  {
    int[] a = {1,2,3,4,5};
    System.out.println("Length of array " + a.length);
  }
}

Two Dimensional Array – Java

  class Main
  {
    public static void main(String args[])
    {
      int[][] a = {{1,2}, {3,4}};
      System.out.println("Content of array " + a[0][1]);     
      System.out.println("Length of array " + a[0].length);
    }
  }

OP: Content of array 2
Length of array 2

public class Main11
{
public static void main(String args[])
{
String[] arrName = new String[5];
int[] arrAge = {21, 25, 24, 26, 27};
char[] arrSection = {'A', 'B', 'C', 'D', 'E'};

arrName[0] = "Mugil";
arrName[1] = "Vinu";
arrName[2] = "Madhavan";
arrName[3] = "Adhavan";
arrName[4] = "Suryan";

//Method 1
for(int i=0;i<arrName.length;i++)
{
if(arrName[i] != null)
System.out.println(arrName[i]);
}

//Method 2
//For - Each Method
for(String item : arrName)
{
System.out.println(item);
}

//Method 3
int j =0;
while(j<arrAge.length)
{
System.out.println(arrAge[j]);
j++;
}

//Method 4
int k=0;
do
{
System.out.println(arrSection[k]);
k++;
}while(k<arrSection.length);
}
}