This question already has an answer here:
Here is some code
package deleteit;
import java.lang.*;
import java.io.*;
import java.util.*;
public class Deleteit {
public static void main(String[] args) throws IOException {
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
ArrayList<Integer> arr1=new ArrayList<Integer>();
arr1.add(100000);
arr1.add(1);
arr1.add(100000);
arr1.remove(1);
if(arr1.get(0)==arr1.get(1))
{
System.out.println("GUd");
}
else
System.out.println("damnit");
}
}
Now Gud should be printed as 100000 is equal to 100000 as 1 gets removed from the ArrayList so it is left with 100000 and 100000 . So why does damnit gets printed ?
Is that a BUG?
Aucun commentaire:
Enregistrer un commentaire