- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Java Program to check if none of the string in the list matches the condition
First, create a List with String elements:
List<String> myList = new ArrayList<>(); myList.add("pqr"); myList.add("stu"); myList.add("vwx"); myList.add("yza"); myList.add("bcd"); myList.add("efg"); myList.add("vwxy");
Use the noneMatch() method to check if none of the above string in the myList begins with a specific letter:
myList.stream().noneMatch((a) -> a.startsWith("f"));
TRUE is returned if none of the string begins with the specific letter, else FALSE.
The following is an example to check if none of the string in the list matches the condition:
Example
import java.util.ArrayList; import java.util.List; public class Demo { public static void main(final String[] args) { List<String> myList = new ArrayList<>(); myList.add("pqr"); myList.add("stu"); myList.add("vwx"); myList.add("yza"); myList.add("bcd"); myList.add("efg"); myList.add("vwxy"); boolean res = myList.stream().noneMatch((a) -> a.startsWith("f")); System.out.println("No match for the starting letter as f? = "+res); } }
Output
No match for the starting letter as f? = true
Advertisements
To Continue Learning Please Login
Login with Google