# Java programs

## Swap three variables in java without temporary variable

Let’s learn swap three variables in java without 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 temporary variable. public class SwapThreeNumbersWithoutTemp { static int num1, num2, num3; public static void main(String[] args) { num1 = 30; num2 =…

Read More Swap three variables in java without temporary variable

## Java program to calculate average of 3 numbers

Let’s learn java program to calculate average of 3 numbers. Java program to calculate average of 3 numbers In program to calculate average of 3 numbers first get input from user using nextDouble() method of Scanner class and storing in three variables number1, number2 and number3. These variables are then passed to calculateAverage() method to…

Read More Java program to calculate average of 3 numbers

## Reverse an array without using another array in java

Let’s learn reverse an array without using another array in java. Reverse an array without using another array in java To reverse an array without using another array we are using for loop which loops till middle index of given array and then swap first number with the last number, swap second number with second…

Read More Reverse an array without using another array in java

## Reverse a string in java without using reverse function

Let’s learn reverse a string in java without using reverse function. Reverse a string in java without using reverse function Here are ways to reverse a string without using reverse function. One using for loop, while loop, and recursion. Here’s the program to reverse a string using for loop without using reverse method. for loop…

Read More Reverse a string in java without using reverse function

## Java program to calculate compound interest

Let’s learn java program to calculate compound interest. Java program to calculate compound interest To calculate compound interest here’s the formula. P (1 + R/n) (nt) – P In compound interest formula, P – is principal amount. R – is annual interest rate. t – is time the money invested or borrowed. n – number…

Read More Java program to calculate compound interest

## Multiplication table in java using array

Let’s learn multiplication table in java using array. Multiplication table in java using array Here’s the java code for multiplication table using two dimensional array and nested for loop. public class MultiplicationTableUsingArray { public static void main(String[] args) { int[][] arrMultipleTable = new int[10][10]; int row = 1, column = 1; for(int a = 0;…

Read More Multiplication table in java using array