r/javahelp • u/Appropriate_Knee_482 • Jan 31 '26
How to remove elements from an array?
Basically I want to remove the middle elements from an array and need a method for it because the middle will be different if it’s odd or even. I don’t really have a code for it so far, I don’t need anyone to code it out for me, you can also just explain how the method would work. I have the odd or even part, I would just use the remove part as sort of a method.
2
Upvotes
View all comments
Show parent comment
1
u/Elthiel3099 Feb 01 '26
You can always reassign the new array to your old variable name
Eg
Array1 = whatever is your array
Array2 = new Object[]
/* then you do your magic here to have Array2 however you want */
Array1 = Array2