GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Array-Programs/InsertKeyElement.java at master · iambhat/Array-Programs Expand file tree/ Copy pathInsertKeyElement.javaMore file actions 40 lines (34 loc) · 1015 Bytes / Copy pathInsertKeyElement.javaFile metadata and controls40 lines (34 loc) · 1015 Bytes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 package arrays; import java.util.Scanner; class InsertElement{ Scanner sc = new Scanner(System.in); void display(int[] a,int key,int index) { for(int i = a.length;i>index;i++) { a[i] = a[i-1]; a[index] = key; } System.out.println("Array Element After Inserting Key"); for(int i = 0;i<a.length;i++) System.out.println(a[i]); } public void readArray() { System.out.println("Enter the array size :"); int n = sc.nextInt(); int[] a = new int[n]; System.out.println("Enter the array elements"); for(int i=0;i<n;i++) a[i] = sc.nextInt(); System.out.println("Enter the key elemenent to be inserted:"); int key = sc.nextInt(); System.out.println("Enter the index of key elemenent to be inserted:"); int index = sc.nextInt(); display(a,key,index); } } public class InsertKeyElement { public static void main(String[] args) { // TODO Auto-generated method stub InsertElement ie = new InsertElement(); ie.readArray(); } } |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |