
can anyone help me out with this two programs plz?? in a main class ,create an array {4,34,5,3,6,8,1} remove 3 and 5th element and shift following left and adding zero at the end of array... another one is to search a numeric value nd search it plzz...

hi nick, I hope this example will helpful for you. The sample code given below is for removing the elements from the given list of array.
public class JavaRemoveArrayElementExample {
public static void main(String args[])
{
int num[]= {4,34,5,3,6,8,1};
int tempArray[]= new int[num.length];
int tempArray1[]= new int[num.length-3];
int tempArray2[]= new int[num.length-5];
int tempArray1And2[] = new int[(tempArray1.length+
tempArray1.length)-2];
int tempArray3[] = new int[tempArray1And2.length-3];
int tempArray4[] = new int[tempArray1And2.length-4];
int tempArray3And4[] = new int[tempArray3.length+
tempArray4.length];
System.arraycopy(num, 0, tempArray, 0, num.length);
//Removing 3rd position element from original array
System.arraycopy(num, 0, tempArray2, 0, num.length-5);
System.arraycopy(tempArray, 3, tempArray1, 0,
tempArray.length-3);
System.out.println("Array list after removing 3rd " +
"position \n element from the original array list");
for(int i=0; i<tempArray2.length; i++)
{
System.out.println(tempArray2[i]);
}
for(int i=0; i<tempArray1.length; i++)
{
System.out.println(tempArray1[i]);
}
//Merging array list tempArray2 and tempArray1
System.arraycopy(tempArray2, 0, tempArray1And2,
0, tempArray2.length);
System.arraycopy(tempArray1, 0, tempArray1And2,
tempArray2.length, tempArray1.length);
System.out.println("List after merge");
for(int i =0; i<tempArray1And2.length; i++)
{
System.out.println(tempArray1And2[i]);
}
//Removing 5th position element from original array
System.arraycopy(tempArray1And2, 0, tempArray3, 0,
tempArray1And2.length-3);
System.arraycopy(tempArray1And2, 4, tempArray4, 0,
tempArray1And2.length-4);
System.out.println("Array list after removing " +
"5th position \n element from the original list");
for(int i=0; i<tempArray3.length; i++)
{
System.out.println(tempArray3[i]);
}
for(int i=0; i<tempArray4.length; i++)
{
System.out.println(tempArray4[i]);
}
//Merging array list tempArray3 and tempArray4
System.arraycopy(tempArray3, 0, tempArray3And4, 0,
tempArray3.length);
System.arraycopy(tempArray4, 0, tempArray3And4,
tempArray3.length, tempArray4.length);
System.out.println("Final array list after removing 3rd " +
"\n and 5th position elements from the original list");
for(int i = 0; i <tempArray3And4.length; i++)
{
System.out.println(tempArray3And4[i]);
}
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.