How to delete an element from an array in java?
ฝัง
- เผยแพร่เมื่อ 22 ก.ค. 2024
- deleting an element from an array in java,
program to delete an element in an array,
remove a specific element from an array in java,
can we remove element from array in java,
how remove element from array in java,
java delete an element from an array,
javascript delete an element from an array,
delete element from array java by index,
how to remove a element from array in java,
delete an element from array java,
can we delete an element from an array in java,
remove duplicate element from an array in java
what if there are more than 1 element of which you want to remove in the array? (i.e. {1, 2, 3, 3, 4} with element being 3)
Thank you so much for great explanation.
Thank you
👍
sir, please catch the AIOB execption in case element not found
you must have not used same name in the method signature?
Dynamic code likhiye naa..
What IDE do you use?
I think it is Eclipse IDE
Little bit easier one!!
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int a[ ]= {1,2,3,4,5,2};
System.out.println("enter element to be deleted:-");
int b= sc.nextInt();
for(int i=0;i
Here you are not deleting but just printing
he is doing the same
@@keerthishanbhag1137
public class Program
{
static void Main(string[] args)
{
int[] nums = { 1, 2,3,4,5,6,7,8,9,10 };
int x = 3;
List list = new List();
for(int i = 0; i < nums.Length; i++)
{
if(x != nums[i])
{
list.Add(nums[i]);
}
}
foreach(int i in list)
{
Console.WriteLine(i);
}
}
}
YOU SAVED ME BRO OMG I WISH I SAW THIS 10 MINUTES AGO BEFORE MY DUE DATE
thank you so so soooooo much i subscribed because of this 🥹🥹🥹🥹👏👏
I'm still so sad because it's 12 am and my mind isn't working properly if i thought to search this up earlier in stead of trouble shooting I could have submitted my assignment before the deadline.
The only thing I struggled with was not adding the "index" variable like you did, so i kept getting out of bounds error. And i had so much time that I wasted so now it's late, but better late than never i guess
Thank you