write a java program to delete a number from array. te program should contain a method deleteNumber
write a java
te program should contain a method deleteNumber
In this program, you need to write method called 'deleteNumber'.
In this method, you need to delete number from array. So first you need to declare array with numbers in this method.
Then you can declare number which needs to be deleted from array.
After declaring number, you can print all original values of array by using loop.
To delete number, you need to check that number within array. You can check it by writing 'if' condition statement.
If number is found then you need to shift remaining values of array, so that number which needs to be deleted will replace by next value in array.
You can shift values by writing nested loop. After that, you can display modified array values.
Step by step
Solved in 3 steps with 1 images