[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/primary-code-test/Java/master/Others/InsertDeleteInArray.java [Back]  [Original]

package Others;

import java.util.*;

public class InsertDeleteInArray {

  public static void main(String[] args) {
    Scanner s = new Scanner(System.in); // Input statement
    System.out.println("Enter the size of the array");
    int size = s.nextInt();
    int a[] = new int[size];
    int i;

    // To enter the initial elements
    for (i = 0; i < size; i++) {
      System.out.println("Enter the element");
      a[i] = s.nextInt();
    }

    // To insert a new element(we are creating a new array)
    System.out.println("Enter the index at which the element should be inserted");
    int insert_pos = s.nextInt();
    System.out.println("Enter the element to be inserted");
    int ins = s.nextInt();
    int size2 = size + 1;
    int b[] = new int[size2];
    for (i = 0; i < size2; i++) {
      if (i 

Web Proxy Viewer  |  New URL  |  Original Page