if i pass this line "al.remove("haiti");" that's a string object and is not equals to the StringBuilder and it returns to false. i tried with "al.remove(new StringBuilder("haiti"))" but that doesn't work as well. can anyone help?
import java.util.*; public class HelloWorld { public static void main(String[] args) { List <StringBuilder> al = new ArrayList<>(); al.add(new StringBuilder("3")); al.add(new StringBuilder("haiti")); System.out.println(al); System.out.println(al.remove(new StringBuilder("haiti"))); System.out.println(al); } }
https://stackoverflow.com/questions/65867029/how-to-remove-the-stringbuilder-object-from-an-arraylist January 24, 2021 at 12:05PM
没有评论:
发表评论