Try:
tourists.removeAll(Collections.singleton(null));
Read the Java API. The code will throw java.lang.UnsupportedOperationException
for immutable lists (such as created with Arrays.asList
); see this answer for more details.
More Related Contents:
- Why is printing “B” dramatically slower than printing “#”?
- How to compare variables in a loop, java
- Basic Looping in Java
- ArrayList, Loop and requisite if can not work that i want – Java 11
- Nested for loop in java. Am I allowed to declare a variable in the outer and increment it in the inner?
- Difference between declaring variables before or in loop?
- Is there a performance difference between a for loop and a for-each loop?
- How does a for loop work, specifically for(;;)?
- Is there a way to access an iteration-counter in Java’s for-each loop?
- ConcurrentModificationException when adding inside a foreach loop in ArrayList [duplicate]
- Performance of traditional for loop vs Iterator/foreach in Java
- Creating a triangle with for loops
- A for-loop to iterate over an enum in Java
- Is there any way to do n-level nested loops in Java?
- Post increment operator not incrementing in for loop [duplicate]
- Should try…catch go inside or outside a loop?
- Null check in an enhanced for loop
- Breaking out of a for loop in Java [closed]
- Hash Set and Array List performances
- Java: how much time does an empty loop use?
- How to optimize for-comprehensions and loops in Scala?
- Better way to find index of item in ArrayList?
- Using for loop inside of a JSP
- Java: For-Each loop and references [duplicate]
- Remove object from ArrayList with some Object property
- Java number sign and asterisk [closed]
- Retrieving a random item from ArrayList [duplicate]
- Java Method invocation vs using a variable
- When will JVM use intrinsics
- Sorting ArrayList of Objects by Object attribute