Java program to reverse a string

In this post we will learn how to reverse a string in java. Problem Here is example of the problem  – Example 1: Input :  s = “abc” Output : s = “cba” Example 2: Algorithm to Reverse a String: Take or input a String. store it in variable “s”. Take a string rev and … Read more

Java Program to check if a String is Palindrome or not

In this post we will go through the java string program to check if a String is Palindrome or not. We will also run the examples and corresponding output. A string is called a palindrome if the reverse of that string is same as the original string. For example: level, madam, etc. Problem : simple … Read more

Java Program to Check a Number is Palindrome or Not

In this post we will explore the basic java program to check a number is palindrome or not and explaining the concept of palindromic numbers and how the program works. Palindrome: A palindrome number is a number that remains the same when its digits are reversed. For example, 121 ,12321 are palindrome numbers, but 1234 … Read more

Find the Greatest of the Two Numbers in Java

Here, we will learn the basic java program to find the greatest of the two numbers. Problem : simple example of problem :  Input : Enter the first number: 8 Enter the second number: 15  Output : The greater number is: 15 Explanation: In this example, the program compares the two numbers (8 and 15) … Read more

Java Program to Get Input from User

In this post we will learn how to get input from user in java. Java User Input: The Scanner class is used to get user input, and it is found in java.util package. we use the scanner class, to create an object of the scanner class and use any of the available methods found in the … Read more

Prime Number Program in Java

Here, first we understand that what is prime number, Prime Numbers A prime number is a natural number greater than 1, that is divisible by only two numbers: 1 and itself. For Example: 2, 3, 5, 7,11,13……..are the prime numbers. Note: 0 and 1 are not prime numbers. The 2 is the only even prime … Read more

Java Program to Check Leap Year

In this post we will go through basic java program to determine leap year. Logic of Leap Year: 1. The year must be divisible by 400. 2. The year must be divisible by 4 but not 100. For example : 1998 is not a leap year. 2000 is a leap year. 2003 is not a … Read more

Addition of two numbers in java

In this post we will go through the process of adding two numbers in Java. Problem : here is the simple example – Input : Enter the first number: 10 Enter the second number: 5 Output : The sum of the two numbers is: 15. Explanation : In this example, the user entered 10 as the … Read more

Java program to check whether the number is even or odd.

In this post we will discuss how to write a program to check whether the number is even or odd in java first, we understand what Even and Odd is: Even and Odd: if a number is evenly divided by 2 (two) without any remainder, then the number is Even. otherwise, the number is odd. … Read more

%d bloggers like this: