Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Comments on How do I remove an element from a Java array?
Post
How do I remove an element from a Java array?
+4
−1
One way to remove element from array is to replace element with zero. Below is a rough snippet I am sharing:
int N = sc.nextInt();
int pos = sc.nextInt();
int A[] = new int[N];
if(pos == i) {
A[i]=0;
}
But the problem is that size of the array remains the same still. You have only replaced the element with zero.
What extra steps we need to perform along with this?
1 comment thread