Let’s learn program to find area of rectangle using inheritance in java. Program to find area of rectangle using inheritance in java We can calculate area of rectangle using inheritance. Here’s an example. class RectangleDimension { int length; int breadth; } class Rectangle extends RectangleDimension { int area; void findArea() { area = length *…

Read More Program to find area of rectangle using inheritance in java

Let’s learn java program to find area of circle and rectangle using interface. Java program to find area of circle and rectangle using interface We can use interface to calculate area of circle and rectangle. Here’s java program. interface FindArea { double pi = 3.14159265359; double calculate(double a, double b); } class Rectangle implements FindArea…

Read More Java program to find area of circle and rectangle using interface

Let’s learn java program to calculate area of circle rectangle and triangle using switch statement. Java program to calculate area of circle rectangle and triangle using switch statement We can use switch statement to calculate area of circle, rectangle and triangle. import java.util.Scanner; public class FindAreaUsingSwitchStatement { public static void main(String[] args) { Scanner sc…

Read More Java program to calculate area of circle rectangle and triangle using switch

Let’s learn how do you swap three variables in java without using temporary variable? Swap three variables in java without using temporary variable In the below example we are using arithmetic operators to swap three variables without using temporary variable. public class SwapThreeNumbersWithoutTemp { static int num1, num2, num3; public static void main(String[] args) {…

Read More Swap three variables in java without temporary variable

Let’s learn how do you sort in descending order in TreeSet in java? How to sort TreeSet in descending order in java In this post lets sort TreeSet elements in descending order or decreasing order. For this we are using descendingSet() method. This method returns a reverse order view of the elements contained in this…

Read More How to sort TreeSet in descending order in java

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