java program to delete specified integer from an array

Solutions on MaxInterview for java program to delete specified integer from an array by the best coders in the world

showing results for - "java program to delete specified integer from an array"
Christian
06 May 2019
1// Java program to delete specified integer from an array
2import java.util.Scanner;
3public class DeleteSpecifiedInteger
4{
5   public static void main(String[] args)
6   {
7      int num, n, temp = 1, place = 0;
8      Scanner sc = new Scanner(System.in);
9      System.out.println("Please enter number of elements: ");
10      num = sc.nextInt();
11      int[] arrNum = new int[num];
12      System.out.println("Please enter all the elements: ");
13      for(int a = 0; a < num; a++)
14      {
15         arrNum[a] = sc.nextInt();
16      }
17      System.out.println("Enter the element you want to delete: ");
18      n = sc.nextInt();
19      for(int a = 0; a < num; a++)
20      {
21         if(arrNum[a] == n)
22         {
23            temp = 1;
24            place = a;
25            break;
26         }
27         else
28         {
29            temp = 0;
30         }
31      }
32      if(temp == 1)
33      {
34         for(int a = place + 1; a < num; a++)
35         {
36            arrNum[a - 1] = arrNum[a];
37         }
38         System.out.println("After deleting element: ");
39         for(int a = 0; a < num - 2; a++)
40         {
41            System.out.print(arrNum[a] + ",");
42         }
43         System.out.print(arrNum[num - 2]);
44      }
45      else
46      {
47         System.out.println("Element not found!!");
48      }
49      sc.close();
50   }
51}
Léandre
07 Jan 2020
1import java.util.Scanner;
2
3public class ElemRemoval {
4
5    public static void main(String[] args) {
6        Scanner in = new Scanner(System.in);
7        int[] intArr = {1, 2, 5, 12, 7, 3, 8};
8        System.out.print("Enter Element to be deleted : ");
9        int elem = in.nextInt();
10        
11        for(int i = 0; i < intArr.length; i++){
12            if(intArr[i] == elem){
13                // shifting elements
14                for(int j = i; j < intArr.length - 1; j++){
15                    intArr[j] = intArr[j+1];
16                }
17                break;
18            }
19        }
20      
21        System.out.println("Elements -- " );
22        for(int i = 0; i < intArr.length - 1; i++){
23            System.out.print(" " + intArr[i]);
24        }                
25    }
26}
queries leading to this page
remove one element from array javaremove by index from array in javajava remove element to arrayremoving element from array in javadelete item from array javahow to display a array elements in a listbox in c 23java remove element arrayadd and remove elements from array javaremove from int array javaclear value at index arrayjavajava how to remove element from arrayjava arrays remove elementjava remove from araydelete item in array javadelete first element char array javaremove array element in javaremove method in array in javadeleting item from array javaremove an element from a java arrayremove from middle of array in javaremove elemennt from array javaremove a element form array javaremove a part of an array javaremove element from an array in javahow to remove an element from an array in java 5chow to remove an array element in javaremove index of array javaremove an element in an array in java 3fremove element array javahow to delete a number in array in javahow to remove an element from an arrray in javahow to delete something from an array javahow to remove elemt from array javahow to remove a element from an array in javadelete array elements javaremove something from an array java importjava remove one element from arrayhow to remove values from an array javahow to remove an element from an array in javajava remove array indexdelete array value javaonly delteing a certain deparment in a array javahow to remove a word from array in javadeleting elemets in array in javaremove item in array java and how to delete an int from an arrayjava how to remove something from an arrayremove items from an array javajava remove array element fromhow to delete one specific position in an arrayremove element in array java functionremove method for array javahow to remove a value from particular index of array in javajava remove elements from arrayjava remove element from array functionomit from array javahow to remove array in javahow to remove an array in javahow to delete element from array using delete javadelete index from array javahow to delete an element in an array javajava array remove item at specifci indexdelete number array javajava how to remove elements from an arrayhow to create a method in java that remove a number from an arraydelete a item in array javahow to remove element from an array in javahow to remove an element in an array in javamethod to remove from array javaremove aaray 5bi 5d from array javaerase an array javaremove an array element javajava delete value from arrayjava remove element in arrayarray erase element s javahow to delete element from an array in javajava delete an element from arraydelete an item in array javajava array removedelete from an array javahow to remove a value from an array javahow remove an element from an array in javaremove something form array javajava delete a part of a arrayjava remove from an arraypop and element from array javahow to delete an element from an array in javajava array how to remove elementhow to remove an item in an array javajava array reomving a elemntremove array element from the given position javahow to remove element of array in javahow to remove elements from an array in javahow to erase element in array in javahow to remove element from end of array in havajava deleting array elementsremoveall from array javadelete an element in array javaarray remove function javaremove an int in an array of int javahow to remove and element in array in javahow to delete from an array in javaremove index in array javaremove one object from array javadelete in array javahow to remove an item from an array in javajava how to remove an element from an arrayremove item from array javahow to remove and element in an array in javajava code to delete element from arrayjava to delete an elemrnt in an arrayhow to delete a element in normal array javajava array delete itemremove elemnt from array javahow to you delete element of array in javahow to remove info from a array in javaremove element by index from array javadelete function for arrays in javadelete element from aarray in javahow to create a method in java that remove a number from an int arrayhow to remove an object from an array in javaremove the element from array in javapop element from array javahow to delete an element form an array by index java methoddelete elemnt from array in javadelete element in javas arrayjava remove from arrayremove element in java arrayarray delete item javajava method to remove elements from an arrayremove element function in java arraysremove index from array javahow to remove to an array javahow to remove a class from a specified index in an arrayremove index fromarray javadelete an element in an array javajava remove element from array 5cdelete element from array javajava how to remove index from arraycan we remove an element in array javahow to delete an element of an array with a for loop javahow to delete element from array javaremove an element from int array in javaremove element from int array javahow to delete an element from array javahow to delete certain items in an array javaremove elements from array javaremoving an element in an array javahow to remove element at the end of an arrya in javadelete number from array javadeleting an element from array javaremoving array element javahow to remove an elementi in a specific index in javaremove an index from array in javahow to remove an items from array javahow to delete an element from an array javahow to remove an index from an array javajava delete item arraysimple java program to delete an element in an arrayhow to remove in array javaremove number in array javaarrey index value delet in javaremoving an index from an array java stringhow to delete a value from an array javahow to remove from array in javaremove and array element javadelet element from index in javadelete an array element in javaremove int from array at positionjava remove array elementhow to delete from an array javaremove element froim array javahow to remove element in array in javaremove number from array inplace javahow to remove and element from array javaarray java removedelete a method in javaremove element from array in javaremove an int in an arraymethod to delete element from array javaremove an element of an array javadelete value from array in javajava how to delete an element from an arraydelete element from array in java removing element from an array in javahow to remove elements in array javahow to remove element from a string array in androidremove method from array javaarray delete item java 27delete an array javaremoving an index from an array javaremove element from array by index in javahow to remove a element from an array javafunction to remove element from array in javahow to remove an element in array in javajava delete item from arrayhow to remove from an array javadelete items from array javaremoving an element in array javaremove character from an array in javahow to remove from string array in javahow to remove the perticular element from the array in javahow to remove a value from an arrayremove array javaremove array element from the given positiondelete element from char array javaremove the int values in array which 3e4java how to create a new array after removing elementjava remove item from array by indexarray how to remove element javaremove ellement from array javaremove nth element of array javajava remove from an objects arrayjava delete contents of arrayremove array elements javaarray class in java for removing elementsremoving in array javahow to remove item from array javadeletion in array javajava array exclude itemhow to remove an element in an array javahow can i remove a value of an array in index position javajava int array remove element and add how to remove element from java arrayhow to remove elements in an array javadelete an index from array javaarray delete javadelete array element javaremove an element from array javajava remove an element from an arrayremoving elements from an array javaremove specific element from array java inbuilthow to remove elemenhow to remove an element from array in javaarrays remove in javajava remove element from string arratremoving element from array javaremove elem fromr array javaremove something from an array javajava code to remove an element of an array from a given positionhow to delete an element from an array in entity javajava removing value in arrayhow to delete element from arrayin javadelete an element in an array in javahow to remove element at that position in javadelete an element from array javaremove element from array java remove methodremove array by index javaremove item in array javajava delete number from arrayremoving element in array javahow to remove an element from string array in javajava remove array how to remove values from array in javahow to remove an entire array in javaarray delete programin javajava remove elements from an arrayremoving an element from an array in javajava delete a var in arraydelete from inside an array javadelete elements from styarting to end index arrays javajava remove item from arrayhow to remove a element from array in javaremoving from a java arrayremove a given element from array in javasimple code for removing an element from an array javahow to remove items from array javahow to remove from java arraydelete element from array i javahow to remove element from string array in javaarray delete element javadeleting a number fron an array javaremove from array in javaremove elements array javadelete an array in javahow to remove certain index from an array in javadelete value from array javadelete elements from position in array javahow to delete an element from array in javadelete element from array javadelete element from int array javadelete element from array manusallyhow to remove an index from a string array in javaremove element from array javaremove an element in array javahow to use remove method on a array in javahow to delete array element in javaremove an element from an array in javahowt o remove elements from array in javahow to remove element in javaremove character from array javahow to delete value in array javahow to delete array in javahow to remove a value in an array in javajava array remove indexjava removing element from arrayremove element in array javahow to pop an element from an array javahow to clear starting array value in javajava remove items from arrayremove element from arrays javaremove item from an array javadelete element from an array javahow to remove the completely remove an array element in javadeleting an array javahow to remove in array in javaremove specific index out of array javadelete element from array java by indexremove varibale array javadelete element of array javajava array remove by indexhow to remove item at index in array javahow to remove a items from array java how to get rid of elements in an array javaarray remove item javahow to delete an elemnt from an array javahow to remove particular index from array in javahow to remove an element from an array with creating a new onearrays remove element javahow to delete a position in a char array javaremove element in an array in javaint array remove javaremove index from array jaaint eliminateelement 28 29remove element from array jaavaremove location in array javahow to remove a specific type of number from an int array in javaremove an element from an array javahow to remove a number from an array in javaarray delete method in javaremove unwante index from array in javahow to delete a element in array in javajava remove element from arraydelete a character from an array valuehow to delete an elment form specific index in javahow to delete element in an array in javaremove item java array methodshow to delete a array element in javaremove elements from array in javajava array remove elementjava delete an element from an arrayjava how to remove array elementhow to remove element in a array javajava how to remove strings in a arrayhow to delete an array in javaremove an element in an array in javaremove array index in javawrite a java program to remove a specific element from an array java remove index from arraydelete an element in array typescriptremove elements from index 1 to 3 in an array javaremove an item from an array javadeleting element from array in javadelete from array at index javaremove data in array javajava remove from array stringremove in array value is javahow to remove item from array in javahow to delete an item from an array javahow to delete items totally from an array in javahow to erase a array javahow do we remove an element from an array in javaremove element in array in javajava delete element from arrayjava how to remove characters from arrayremove string array from indexjava remove array element by indexjava delete from arrayarray element delete in javaremove the numer from array in ajavadeleting an element from an array in javadeleting element in javaremove first element in array of strings in javajava array remove element at indexremove object from java arraydelete something in an array javahow to delete a element from an array in javahow to delete elements from array in javaremove numbers of an array javadeletion of array in javadelete item in java arrayjava array delete elementhow to remove a value in an array javahow to delete index in array javajava program to delete an element from arrayjava how to remove elemnts from an arrayremove method in java arrayjava how to get rid of an arrayhow to remove an int from an array javajava remove value from arrayhow to remove indexes from arrays in javahow to delete element in array in javaremove item form array javadelete element in array javahow to remove element in array javadeleting a number from an array javadelete from array javaremove an element at specific index from an array in javahow to remove element from array javaremove element from a specific index from an array in javadelete element at specified index javahow to remove one element from array in javajava doesnt delete element out of arrayremove object from array javaarrays remove javaarray java delete elementjava array removevalue functiondelete an element from an array java 5cremove value at index java arrayjava delete in arrayjava delete something from a array by indexjava remove method array as stringremove value array javahow to delete an array javaremove lement from array javadelete from array in javadeleting elements from array in javadelete item from array in javaremove array element function javacan i remove element from array in javadeleting item in array javaremove element of array in javahow to pop element from arrayin javahow to delete array form an array javaremove value from array array javaremove elemeent from array javaremove value from array javajava array delete valuedelete the items from array javato remove the element at the given index in a array in javadeleting values from array javaremove number from array javaremove element from array java indexhow to perform deletion in array in javahow to remove elemtnts from an array in javajava remove int from arrayhow to add an element from array in javascripthow to remove element from array in javadeletion in an array in javaarray delete element index javahow to remove a item by array index in javaarray remove element in javadelete array javadelete index in array javajava 8 remove from arrayarray remove an item javahow to remove value from array in javahow to erase a array in javaremov number from array n javaremove element from array javashow to remove one lement fgrom an array javaremoving an element from an array javaremove entry from array javahow to delete elements from array javahow to remove somethng from the array in javahow to remove the element from the array in javajava program on remove element from string arrayremove index 0 of array in javahow can i delete the value in array in javajava delete element in arraydelete in arra javaremove items from array javaremoving from array javadelete a value in array javaremove from an array javahow to drop given index of element of array in typejava remove int from array and keep indexesremove method is in array or collectionjava program to delete specified integer from an arrayhow to remove a element form array javajava pop item from arrayjava array delete element at indexremove elements from arraay javahow to delete from array javahow to remove a specific element from an array in javahow to remove an entry from an array in javadeleting an element from an array javajava delete arraydelete element in java arrayhow to delete elements in array java java int 5b 5d removehow to delete an element form an array by index javahow to delete an element form an array in javaedelete element from arrauy javahow to delete an element from a specific index in javahow to remove a class from a specific index in an arrayremove an array javajava code to delete an item from an arrayhow to remove an item from an array javadeleting elements from array javafunction to delete an element from an array in javaremove elelmtn from java arraymethod 3a removes a value from the array at a given index javato remove an element from an array at a index in javaremove a element from array in javahow to remove array element in javahow to delete an array element in javahow to remove an index from an array eclipse javahow to delete an element from an array in java in place how to delete a element in array javahow to delete all the elements in an array in javadelete method array javajava how to remove a var from an arrayremove string element from int array javascriptremove a element in array javadeleting element from array javahow to delete an array index javajava how to remove part of an arrayjava array deletehow to remove items from array in javaremove array index javahow to delete element from array in javaremove an item from array javahow to remove an arry from an array javadelete a specific element at index java arraydelete specific element from array javajava how to delete an array elementjava how to remove an element from an array of an arraydelete array item javadelete element from oversize array javahow to remove array elements in javahow to remove an element from array in javahow to delet a number from an array in javadelete number in array javaremoving 28int 29 from arrayremove element of an array javahow to delete the array element in javajava delete elemnt of arrayjava 2b remove from arrayjava drop element of arrayhow to remove thing from array in javaremove array in javaremove array value in javahow to deleate array javaremove element of array javahow to remove soemthng from an array java6 write a java program to remove a specific element from an array how to remove character in array in javaremoving something from an array javajava how to remove int from arrayjava delete the given element from the array 2c if any how to remove an element of an array by index in javadelete an element from an array javaremove element in an array javahow to pop an item from an array in javahow to delete a element fromarray ion javahow to remove an elemtn from an array in javaremove value from array in javajava delete elements from arrayremove specific elemtn in arrayhow to remove an element from an array javaremove from array fixed indexdelete array element in javaremove array element at index javapop elements from array javaremoving array element in javahoe to remove element fro aray javaremove an element from array in javajava remove element from string arrayhow to remove a value from a given index from an array javadelete an array element at index 27k 27 javajava how to delete array elementhow to delete element in array javahow to remove elements from array in javadelete index array javajava array delete elementsremoving an array in javahow to delete elements from an array 3f javajava delecrase delate from arraydeleting array element in javadelete from int array javaremove a value from array and return the same array in javaremove method for array in javahow to delete a number from an arrray in javaarray 2cremove javahow do i remove a character from element in array javadelete an element from an array in javadeleting value out of array javahow to remove an element from an arraylis javahow to remove an element from an integer array in javadelete array in javaarray remove element javajava delete array elementremoving an element from an array function injavaremove from array javaremove in array javamethod to remove element from array javajava remove item from arrrayarray delete element java libraryremove an elemnt from an array javaremove an element from arr in javaarray delete value javsaremove a string from an array javaarray remove javajava removing an element from an arrayhow to remove something from an array javahow to delete an object from an array in javajava how to remove element from string arrayhow do i remove a character from array element 3f javahow to remove value from array javahow to remove an element from the array javadelte array javaarray deletion javajava how to delete part of an arrayhow to take out elements from an array javaarray deletion in javaremoving 1 spot in an arrayremove element out of array by index javadelete a specific element from array javadelete element from particular position javadeleting from array javahow to remove array element at index in javadeleting element in array javajava remove from array by indexhow to remove element of array in javasdelete an integer in int array javaremoving an element from array in javahow to delete array element javahow to erase an array in javaremove an elemet from array javahow to remove from array javahow to remove values from an array in javadelete an string from array javaalgorithm to delete element from array in javadelete an element from an array java programhow to remove from an array in javaremove an element form array javadelete element in array in javaremove int from array javaremove function in array javahow to remove elements of an array in javaremove int from int array javaarrays remove element in java utilremove elements form array javadelete a certain element form a java arrayarrays delete integer javahow delete element from array in javahow to remove an element from an arrayremoving something from array in javaremove from array javasis there any function to remove an array in javadelete something in array javajava code to remove an item from arrayhow to delete a element from a specific index in javahow to remove an element from array javado you need to delete arrays in javajava delaring an arrayhow to remove the starting element in array javaremove an element from arrat javaremove element from java arrayremove element from array java by valuehow to remove an array index in javastrip array javahow to remove a index from a array javajava remove element from arryajava code for delete an element from an arrayarrays remove javajava remove object from arrayjava clear an array of a certain characterremove array element javajava program to remove the first element in an arrremove items in array javadelete a element in array javahow to remove elemet in array javahow to delete value from string array javahow to remove elements from an array javahow to remove a string from string array in javaremove array value in javadeleting an instance of an array java java remove elemetn from arrayjava program to delete specified integer from an array