Let’s learn TreeMap comparator() method in java with examples. Treemap comparator() method in java with examples TreeMap comparator() method returns the comparator used to order the keys in this map, or null if this map uses the natural ordering of its keys. Let’s see example on TreeMap comparator() method for natural ordering. import java.util.Comparator; import…

Read More TreeMap comparator() method in java with examples

Let’s learn to add two matrices in java using bufferedreader. Add two matrices in java using bufferedreader Here’s addition of two matrices using bufferedreader. import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class AddTwoMatrixUsingBufferedReader { public static void main(String[] args) throws NumberFormatException, IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int a, b; int[][] arr1 =…

Read More Add two matrices in java using bufferedreader

Let’s learn java program to calculate average of 3 numbers. Java program to calculate average of 3 numbers In program to find average of 3 numbers in java we are taking input from user using nextDouble() method of Scanner class and storing in three variables number1, number2 and number3. These variables are then passed to…

Read More Java program to calculate average of 3 numbers

Let’s learn how to sort an array without using sort method in java? How to sort an array without using sort method in java In the below program on how to sort an array without using sort method we are not using Arrays.sort() method to sort given array. Meanwhile we are sorting array elements in…

Read More How to sort an array without using sort method in java

Let’s learn how to sort characters alphabetically in a string in java? Sort characters alphabetically in a string in java To sort string characters alphabetically we do not have any method in String class. So we are using different methods in sorting characters alphabetically in a string. So here the first method we are applying…

Read More Sort characters alphabetically in a string in java

Let’s learn how do you reverse an array without using another array java? Reverse an array without using another array in java To reverse an array without using another array we are using for loop which loops till middle index of given array and then swap first number with the last number, swap second number…

Read More Reverse an array without using another array in java