## Program to find area of rectangle using inheritance in java

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

## Java program to find area of circle and rectangle using interface

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

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

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

## swap three variables in java without using temporary variable

Let’s learn to 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) { num1 =…

Read More swap three variables in java without using temporary variable

## Create dynamic 2d array in java

Let’s learn to create dynamic 2d array in java. Create dynamic 2d array in java Dynamic two dimensional array is one array where user can add and remove rows and columns on need and can have varying number of rows and columns. To implement dynamic two dimensional array we use a combination of List(can shrink…

Read More Create dynamic 2d array in java

## How to convert string to date in Java 8

Let’s learn how to convert string to date in Java 8. How to convert string to date in Java 8 Let’s see example in converting String to Date using LocalDate class and DateTimeFormatter class in Java 8. Syntax: LocalDate ld = LocalDate.parse(date, formatter); parse() method returns the parsed local date, not null. Let’s see convert…

Read More How to convert string to date in Java 8

## How to sort ArrayList in java

Let’s learn how to sort ArrayList in java. How to sort ArrayList in java In java, ArrayList or LinkedList class objects are stored in unordered way. So to sort an ArrayList we are using Collections.sort() and reverseOrder() method. In this post we are going to sort arraylist in java in ascending and descending order. Collections.sort()…

Read More How to sort ArrayList in java

## Difference between hashset and treeset in java

Let’s learn difference between hashset and treeset in java. Difference between hashset and treeset in java HashSet TreeSet hashset do not maintain any order. sorted according to natural order. If not use compareTo() method. uses equals() method for comparison. uses compareTo() method for ordering two objects. hashset is implemented using HashTable. TreeSet is implemented using…

Read More Difference between hashset and treeset in java

## How to sort treeset in descending order in java

Let’s learn how to sort treeset in descending order 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 set. import…

Read More How to sort treeset in descending order in java