Java programs

Let’s learn prime number program in java using scanner. Prime number program in java using scanner To check prime number program using scanner first get input from user using nextInt() method of Scanner class. This user input number is stored in integer variable ‘number’. Then set integer variables ‘s’ and ‘e’ to one and zero.…

Read More Prime number program in java using scanner

Let’s learn java program to print prime numbers in a given range. Java program to print prime numbers in a given range To print prime numbers beween two ranges first user enters starting and ending range using nextInt() method of Scanner class. In the next step using for loop find prime numbers between starting and…

Read More Java program to print prime numbers in a given range

Let’s learn pascal’s triangle in java using recursion. Pascal’s triangle in java using recursion Here’s program to print pascal’s triangle using recursion. import java.util.Scanner; public class RecursionPascalTriangle { public static void display(int num) { for(int a = 0; a < num; a++) { for(int b = 0; b <= a; b++) { System.out.println(pascalTriangle(a, b) +…

Read More Pascal’s triangle in java using recursion

Let’s learn pascal triangle program in java without using arrays. Pascal triangle program in java without using arrays To write a program to print pascal triangle without using arrays we are using two for loops. Outer for loop print number of rows and inner for loop prints numbers in each rows. Here’s java program. import…

Read More Pascal triangle program in java without using arrays

Let’s learn java program to check palindrome number using recursion. Java program to check palindrome number using recursion Recursive function is an approach where function calls itself. Here’s the palindrome number using recursion in java or java program to check palindrome number using recursion. public class PalindromeNumberRecursion { static int palindromeRecursion(int number, int temp) {…

Read More Java program to check palindrome number using recursion

Let’s learn string palindrome in java without using reverse method. String palindrome in java without using reverse method In java program to check if any string is palindrome without using reverse method first convert user entered string to char array. In the next step read char from char array from last index. Lastly concatenate. Let’s…

Read More String palindrome in java without using reverse method

Let’s learn java program bubble sort in ascending and descending order. Java program bubble sort in ascending and descending order Here’s the program for bubble sort in ascending order & descending order. Bubble sort ascending order – To sort in ascending order the logic is arrInput[b] > arrInput[b + 1]. import java.util.Scanner; public class BubbleSortAscending…

Read More Java program bubble sort in ascending and descending order