# Java programs

## Java program to print prime numbers from 2 to N

Let’s learn java program to print prime numbers from 2 to N. Java program to print prime numbers from 2 to N Prime number is one which is divisible by 1 and itself. In the below java program let’s find prime numbers from 2 to N. First we read input from user or maximum number…

Read More Java program to print prime numbers from 2 to N

## Prime number program in java using scanner

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

## Java program to print prime numbers in a given range

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 in a given range 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…

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

## Pascal’s triangle in java using recursion

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

## Pascal triangle in java using array

Let’s learn pascal triangle in java using array. Pascal triangle in java using array Here’s the algorithm on pascal triangle using arrays. First we have to use two dimensional array. First declare integer variables num, a, b, arr[][], p. Let user input value of variable ‘num’. Now set p = num – 1. In the…

Read More Pascal triangle in java using array

## Pascal triangle program in java without using arrays

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

## Java program to check palindrome number using recursion

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

## String palindrome in java without using reverse method

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

## Java program bubble sort in ascending and descending order

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