fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception {
  11. int[]my_array ={10,20,30,40,50,60};
  12. System.out.println("Original Array;"+Arrays.toString(my_array));
  13.  
  14. //Remove the second element(index->1,value->20) of the arra
  15. int removeIndex =1;
  16.  
  17. for(int i =removeIndex; i<my_array.length-1; i++){
  18. my_array[i]=my_array[i+1];
  19. }
  20.  
  21. System.out.println("After removing the second element:"+Arrays.toString(my_array));
  22. }
  23. }
Success #stdin #stdout 0.12s 52316KB
stdin
Standard input is empty
stdout
Original Array;[10, 20, 30, 40, 50, 60]
After removing the second element:[10, 30, 40, 50, 60, 60]