# Java programs

## Reverse factorial program in java

Let’s learn reverse factorial program in java. Reverse factorial program in java Here’s reverse factorial program. Here we are using for loop to compute the reverse factorial. import java.util.Scanner; public class ReverseFactorialProgram { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println(“Please enter a number to compute reverse factorial: “); int number…

Read More Reverse factorial program in java

## Factorial from 1 to 10 in java

Let’s learn factorial from 1 to 10 in java. Factorial from 1 to 10 in java Here’s the factorial from 1 to 10. We are using for loop which loops from 1 to 10. public class FactorialFrom1To10 { public static void main(String[] args) { int count; long factorial = 1; System.out.printf(“%4s%30s\n”, “Number”, “Factorials”); for(count =…

Read More Factorial from 1 to 10 in java

## 4 Digit Armstrong number in java

Let’s learn 4 digit armstrong number in java. 4 Digit Armstrong number in java Now let’s learn armstrong number in java of 4 digits code with an example. Here’s the java program that checks whether the given 4 digit number is 4 digit armstrong number or not. public class ArmstrongNumberDemo { public static void main(String[]…

Read More 4 Digit Armstrong number in java

## Armstrong number in java using recursion

Let’s learn what is armstrong number in java using recursion? Armstrong number in java using recursion Let’s check for armstrong number using recursion. In java, a function that calls itself is called recursion. Here’s the armstrong number program in java using recursion. import java.util.Scanner; class RecursionArmstrong { int number, sum; RecursionArmstrong(int num1) { number =…

Read More Armstrong number in java using recursion

## Display even and odd numbers in java using for loop

Let’s learn to display even and odd numbers in java using for loop. Display even and odd numbers in java using for loop In even odd program in java using for loop, first get input (maximum number) from user using nextInt() method of Scanner class. This number is stored in integer variable ‘number’. Here we…

Read More Display even and odd numbers in java using for loop

## Java program to insert an element at specific position in an array

Let’s learn java program to insert an element at specific position in an array. Java program to insert an element at specific position in an array To insert an element at specific position in an array first user enters size of the array using nextInt() method of Scanner class and then enters all elements of…

Read More Java program to insert an element at specific position in an array

## Remove element from a specific index from an array in java

Let’s learn remove element from a specific index from an array in java. Remove element from a specific index from an array in java Now let’s learn to remove element from array by index. So to remove an element by index from an array first we have to find element at specified index and remove…

Read More Remove element from a specific index from an array in java

## Java program convert decimal to octal using while loop

Let’s learn java program convert decimal to octal using while loop. Java program convert decimal to octal using while loop Let’s learn to convert decimal number to octal using while loop. import java.util.Scanner; public class DecimalToOctalUsingWhileLoop { public static void main(String[] args) { int decimal; Scanner sc = new Scanner(System.in); System.out.println(“Please enter decimal number: “);…

Read More Java program convert decimal to octal using while loop

## Java program to convert decimal to hexadecimal using recursion

Let’s learn java program to convert decimal to hexadecimal using recursion. Java program to convert decimal to hexadecimal using recursion Here’s the program to convert decimal to hexadecimal using recursion. import java.util.Scanner; class DecimalToHexaDemo { char[] charHexa ={‘0′,’1′,’2′,’3′,’4′,’5′,’6′,’7′,’8′,’9′,’A’,’B’,’C’,’D’,’E’,’F’}; int num; String strHex = “”; String hexadecimal(int h) { if(h != 0) { num = h…

Read More Java program to convert decimal to hexadecimal using recursion

## Decimal number to binary in java using recursion

Let’s learn decimal number to binary in java using recursion. Decimal number to binary in java using recursion Here’s the program to convert decimal to binary using recursion. The logic to convert decimal to binary using recursion is, if(decimal == 0) return 0;else return(decimal % 2 + 10 * toBinary(decimal / 2)); public class DecimalToBinaryUsingRecursion…

Read More Decimal number to binary in java using recursion