Java 8 for loop

Posted Posted in Core Java, 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 :  

  Java 5 added the forEach loop that made looping with collections easier as it removed declaration of the looping variable and checking length of […]

How to split a string in java

Posted Posted in Core Java

Here are some approaches to split a String in Java.   Using String.split() method Using StringTokenizer   Splitting a string using the split() method   Here is the syntax of the split() method :   public String[] split(String regex, [int limit])   Here, regex is a regular expression that will act as separator for the […]

Convert String to XML Document and XML Document to String in Java

Posted Posted in Java

This article provides utility methods to : Convert an xml document object to string Convert a string to xml document object   First let’s create a class in a package com.techkatak.test.   Now, we need a xml file or string to start with. For this, we can just hardcode the xml string as shown […]

Error Handling in

Posted Posted in Java

In this article, we will learn Error handling in ASP.NET uses the common language runtime (CLR) that provides a way of notifying errors of application in a uniform way. When an error occurs, an exception is thrown. An exception is any error, condition, or unexpected behavior that an application encounters. An exception is an […]

Immutable in Java

Posted Posted in Core 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 […]

Binary Search in Java

Posted Posted in Core Java, Java

This post explains : – Java code for binary search in list – searching lists in java – java code for recursive binary search – java code for iterative binary search   Searching List in Java If a list is not sorted, searching can only be done by element by element by comparison. So, its […]

Reverse a string in java

Posted Posted in Core Java, Java

If you are looking for the following, this article will be of help : – Reverse a string in Java without library functions – String reversal algorithm in java – Reverse a string using StringBuffer or StringBuilder   Reverse a String in Java   Java provides library methods in StringBuffer and StringBuilder to reverse a […]