For loop in Java 8

For loop in Java has changed a lot from the way it first appeared in jdk 1.   Here is an example of the classical for loop :                    // Classic for loop         for(int i=0;i<5;i++){     System.out.println(i);   }   Java 5 added the forEach loop that made looping with collections easier as it removed declaration […]

Java 8 Lambda Expressions

This article provides an introduction to lambda expressions introduced in JDK 8 and explains how to run them using functional interfaces. What is a Lambda expression in Java ?   A Lambda expression represents an Anonymous method.   Anonymous method concept is similar to that of an Anonymous class… the difference being it implements a […]

Different ways to reverse a String in Java

In this article, we will discuss different approaches to reverse a String in Java. Reverse a String in Java using StringBuffer and StringBuilder library functions String reversal algorithms in Java Reverse a String using Recursion Reverse a String word by word in Java Reverse order of words in a String in Java   Reverse a […]

Immutable in Java

  This articles focuses on the following : What is meant by an Immutable class in Java ? What is the advantage of an Immutable class ? How to create an Immutable class ? What happens when a variable or class is marked final ?   Immutability in Java An object is considered immutable if […]

Split string in Java

In this article, we will see different approaches to split a String in Java.   – Using String split() method – Using StringTokenizer – Algorithm to split a String in Java   Splitting a string using the split() method   Here is the syntax of the split() method :   public String[] split(String regex, [int […]