Category Archives: Coding Practice

Coding Practice Solutions

Java Program to check Palindrome String

This is a Java program to check if a string is a palindrome or not. A a string is a palindrome if it remains unchanged when reversed, for example “mam” is a palindrome as reverse of “mam” is “mam” whereas “public” is not a palindrome. Some other palindrome strings are “dad”, “madam”, “abcba”. Note: Approach to check if… Read More »

Arithmetic Operation Using Lambda Expression

A lambda expression consists of the following: A comma-separated list of formal parameters enclosed in parentheses. The CheckPerson.test method contains one parameter, p, which represents an instance of thePerson class.Note: You can omit the data type of the parameters in a lambda expression. In addition, you can omit the parentheses if there is only one parameter. For example, the following lambda expression… Read More »

Removing duplicates Elements from List

This program uses Java collections’ List. First we store some elements in Java ArrayList and then store it in LinkedHashSet. As we know that java sets have property to have unique elements only, so once we copy our List into LinkedHashSet, it removed the duplicate elements of course. Obviously, we have many other simpler ways to perform this operation.… Read More »