Java8 Predicate Example

Java8 Predicate Example Program   import java.util.Arrays; import java.util.List; import java.util.function.Predicate; public class Java8Tester {    public static void main(String args[]){       List<Integer> list = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9);            // Predicate<Integer> predicate = n -> true       // n is passed as parameter to test method of Predicate interface       // test […]

Java program for checking files in a directory

Before NIO.2, iterating through files in a directory involved writing recursive code to go through subdirectories and files.   NIO.2 handles the recursion details internally. We just have to provide information about what it needs to do when a directory is found.     We create a FileVisitor object and provide implementation for the visitFile() […]

Java program for ArrayList operations

ArrayList operations program   In this java program, we will create an ArrayList of Soccer players and provide the users options to add, remove or update players in the ArrayList.     Following operations are displayed :   – Iterating over the ArrayList using iterator (we can also use For-Each or ListIterator here)   – […]

Java program for LinkedList operations

LinkedList operations program   In this java program, we will create a linkedlist of Soccer players and provide the users options to add, remove or update players in the linkedlist.     Following operations are displayed :   – Iterating over linked list using For Each (we could also use an Iterator here)   – […]

Java : Different algorithms to check if two Strings are Anagrams

In this article, we will see different Java algorithms to determine if two Strings are anagrams of each other. These programs can be used to check if a String is a permutation of another String.   What is an Anagram ? Two String or words are said to be Anagrams of each other if they […]