Java programs

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

Let’s learn to add two matrices in java using bufferedreader. Add two matrices in java using bufferedreader Here’s addition of two matrices using bufferedreader. import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class AddTwoMatrixUsingBufferedReader { public static void main(String[] args) throws NumberFormatException, IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int a, b; int[][] arr1 =…

Read More Add two matrices in java using bufferedreader

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

Read More Java program to calculate average of 3 numbers

Let’s learn to 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…

Read More Reverse an array without using another array in java

Let’s learn to 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…

Read More Reverse a string in java without using reverse function

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