Java programs

Let’s learn java program to print armstrong numbers between given range. Java program to print armstrong numbers between given range In the below program to print armstrong numbers between given range first user inputs given range, that is, starting number and ending number using nextInt() method of Scanner class. Finally print armstrong numbers between given…

Read More Java program to print armstrong numbers between given range

Let’s learn java program to calculate sum of even and odd numbers in an array. Java program to calculate sum of even and odd numbers in an array In the below java program first user enters number of elements in an array or size of an array and also array elements using nextInt() method of…

Read More Java program to calculate sum of even and odd numbers in an array

Let’s learn java program to print odd and even numbers between 1 and 100. Java program to print odd and even numbers between 1 and 100 In the below program to print odd and even numbers between 1 and 100 we are using two for loops. One to print even numbers and another to print…

Read More Java program to print odd and even numbers between 1 and 100

Let’s learn count number of even and odd elements in an array in java. Count number of even and odd elements in an array in java To count the even and odd numbers in an array first user is allowed to enter size and elements of one dimensional array using nextInt() method of Scanner class.…

Read More Count number of even and odd elements in an array in java

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 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 find 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 find area of circle and rectangle. Here’s the java program. interface FindArea { double pi = 3.14159265359; double calculate(double a, double b); } class Rectangle implements…

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. Java program to calculate area of circle rectangle and triangle using switch 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 = new…

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