Let’s learn java program to put even & odd elements of an array in 2 separate arrays. Java program to put even & odd elements of an array in 2 separate arrays In the below program to put even & odd elements of an array in 2 separate arrays first user is allowed to enter…

Read More Java program to put even & odd elements of an array in 2 separate arrays

Let’s learn how do you remove last element from arraylist in java? How to remove last element from ArrayList in java To remove last element from arraylist use two overloaded remove() method of ArrayList. They are, remove(int index): accepts the index of the element to be removed. Pass index of last element to delete last…

Read More How to remove last element from ArrayList in java

Let’s learn java program to find maximum and minimum number without using array. Java program to find maximum and minimum number without using array In the below example we are using Integer.MAX_VALUE and Integer.MIN_VALUE to find maximum value and minimum number without using array. Here’s the java program. import java.util.Scanner; public class MaximumMinimumWithoutArray { public…

Read More Java program to find maximum and minimum number without using array

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