Java programs

Let’s learn transpose of a matrix in java without using second matrix. Transpose of a matrix in java without using second matrix Here’s the program for transpose of a matrix without using second matrix or another array. import java.util.Scanner; public class WithoutSecondMatrix { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int…

Read More Transpose of a matrix in java without using second matrix

Let’s learn transpose of a matrix in java using BufferedReader. Transpose of a matrix in java using BufferedReader Here’s the transpose of a matrix using BufferedReader. import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class TransposeMatrixDemo { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); System.out.print(“Please enter number of rows:…

Read More Transpose of a matrix in java using BufferedReader

Let’s learn to check leap year or not using conditional operator in java. Check leap year or not using conditional operator in java To check if year is leap year or not using conditional operator first we have to read value from user using nextLong() method of Scanner class. Then using ternary operator check given…

Read More Check leap year or not using conditional operator in java

Let’s learn to convert string to hexadecimal in java. Convert String to hexadecimal in java To convert a string to hexadecimal first get input from user using next() method of Scanner class. In the next step create StringBuffer object. Now convert user entered string to character array using toCharArray() method of String class. Now using…

Read More Convert String to HexaDecimal in java

Let’s learn convert binary to decimal in java using recursion. Convert binary to decimal in java using recursion Now let’s learn recursion program to convert binary to decimal. public class BinaryToDecimalRecursion { static int binaryToDecimal(String strBinary, int a) { int size = strBinary.length(); if(a == size – 1) return strBinary.charAt(a) – ‘0’; return((strBinary.charAt(a) – ‘0’)…

Read More Convert binary to decimal in java using recursion

Let’s learn Floyd’s triangle number pattern using while loop in java. Floyd’s triangle number pattern using while loop in java Here is the program to print floyd’s triangle number pattern using nested while loop. Let’s see floyd’s triangle number pattern. public class FloydTriangleWhileLoop { public static void main(String[] args) { int a = 1; while(a…

Read More Floyd’s triangle number pattern using while loop in java

Let’s learn floyd’s triangle star pattern in java. Floyd’s triangle star pattern in java Let’s learn java program to print floyd’s triangle with stars in java. Here we are using nested for loop to print floyd’s triangle star pattern. import java.util.Scanner; public class FloydTriangleStars { public static void main(String[] args) { Scanner sc = new…

Read More Floyd’s triangle star pattern in java

Let’s learn inverted floyd triangle of numbers in java. Inverted floyd triangle of numbers in java Now let’s learn to print inverted floyd triangle of numbers in java. Here’s the java program. import java.util.Scanner; public class InvertedFloydTriangleDemo { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.print(“Please enter size limit: “); int…

Read More Inverted floyd triangle of numbers in java