how can i remove an element in my array without using special commands like hashmap....i have made many parts of it...just the delete part...
import java.io.*;
public class Super
{
public static void main(String args[])throws IOException
{
String temp;
int num[]=new int[10], choice,index,value,i,search,found=0;
BufferedReader in;
in = new BufferedReader(new InputStreamReader(System.in));
for(i=0;i<10;i++)
{
System.out.print("Enter a Number: ");
temp=in.readLine();
num[i]=Integer.parseInt(temp);
}
do
{
System.out.println("\n[1]Insert");
System.out.println("[2]Delete");
System.out.println("[3]Search");
System.out.println("[4]View");
System.out.println("[5]Exit");
System.out.print("Enter Choice:");
temp=in.readLine();
choice=Integer.parseInt(temp);
switch(choice)
{
case 1:
System.out.print("Enter Index:");
temp=in.readLine();
index=Integer.parseInt(temp);
System.out.print("Enter New Value:");
temp=in.readLine();
value=Integer.parseInt(temp);
num[index]=value;
System.out.println("The Values are:");
for(i=0;i<10;i++)
System.out.print(num[i] + " ");
break;
case 2://problem in deleteng...dont know how..
System.out.print("Enter Index:");
temp=in.readLine();
index=Integer.parseInt(temp);
index='\0';
System.out.println("The Remaining Values are:");
for(i=0;i<10;i++)
System.out.print(num[i] + " ");
break;
case 3:
System.out.print("Enter Number to be searched:");
temp=in.readLine();
search=Integer.parseInt(temp);
for(i=0;i<10;i++)
{
if(num[i]==search)
{
found++;
}
}
if(found==0)
{
System.out.println("No match Found!");
}
System.out.print("No. of Elements Found:" + found + "\n");
break;
case 4:
System.out.println("The New Sets of Elements are: ");
for(i=0;i<10;i++)
System.out.print(num[i] + " ");
break;
case 5:
System.out.println("End of Program.");
break;
default:
System.out.println("Invalid Input!");
}
}while(choice!=5);
}
}