Let’s learn recursion in java. Recursion in java Recursion is a process where a method calls itself infinitely or continuously. Recursion program Recursion makes code closely packed and difficult to understand. Here’s an example on infinite recursive function. public class InfiniteRecursiveExample { static void print() { System.out.println(“helloworld”); print(); } public static void main(String[] args) {…

Read More Recursion in java

Let’s learn how to remove duplicates from arraylist in java. How to remove duplicates from ArrayList in java Here the task is to remove duplicates in ArrayList. In the below java program first get given ArrayList with duplicate integer values. Now print ArrayList with duplicate integer values on the console. Create another ArrayList ‘alNew’. Pass…

Read More How to remove duplicates from ArrayList in java

Let’s learn how to remove duplicates from array in java without using collections. How to remove duplicates from array in java without using collections To remove duplicates from array is bit tricky. Because problem with arrays is not finding duplicates, its about removing duplicates. We all know that an array is a static data structure…

Read More How to remove duplicates from array in java without using collections

Let’s learn difference between while and do while loop in java. Difference between while and do while loop in java While loop do while loop In while loop condition is checked first and then statements are executed. In do while loop statements are executed atleast once and then condition is checked. In while loop statements…

Read More Difference between while and do while loop in java

Let’s learn java program to add two numbers using bufferedreader. Java program to add two numbers using bufferedreader In the below program to add two numbers using bufferedreader first get input from user using readLine() method of BufferedReader class. In the next step convert string to integer using Integer.parseInt() method. This method returns the integer…

Read More Java program to add two numbers using bufferedreader

Let’s learn string palindrome in java using stringbuffer. String palindrome in java using stringbuffer First we have to create StringBuffer object ‘sb’. Then pass given string as parameter to the constructor. Now reverse contents of given string using reverse() method of StringBuffer class. In the next step convert StringBuffer object to String using toString() method…

Read More String palindrome in java using stringbuffer

Let’s learn string palindrome in java using array. String palindrome in java using array To do that first convert user entered string into character array using toCharArray() method. In the next step make a copy of user entered string into another character array using copyOf() method of Arrays class. Now reverse array. Compare user entered…

Read More String palindrome in java using array

Let’s learn how to check if a string is in alphabetical order in java. How to check if a string is in alphabetical order in java To check if a string is in alphabetical order or not first store the given string in String variable “strInput”. Before going to next step first create static checkIfAlphabaticOrder(String…

Read More How to check if a string is in alphabetical order in java