Category: Java Examples

python tutorials and learn python

Created with Sketch.

Java Program to Count Number of Digits in an Integer

Java Program to Count Number of Digits in an Integer In this program, you’ll learn to count the number of digits using a while loop and for loop in Java.   Example 1: Count Number of Digits in an Integer using while loop public class NumberDigits { public static void main(String[] args) { int count…
Read more

Java Program to Display Characters from A to Z using a loop

Java Program to Display Characters from A to Z using a loop In this program, you’ll learn to print English alphabets using for loop in Java. You’ll also learn to print only uppercase and lowercase alphabets. In this program, we use a for loop to iterate through the characters from ‘A’ to ‘Z’, and print…
Read more

Java Program to Find LCM of two Numbers

Java Program to Find LCM of two Numbers In this program, you’ll learn to find the lcm of two numbers by using GCD, and by not using GCD. This is done using for and while loops in Java. The LCM of two integers is the smallest positive integer that is perfectly divisible by both the…
Read more

Java Program to Find GCD of two Numbers

Java Program to Find GCD of two Numbers In this program, you’ll learn to find GCD of two numbers in Kotlin. This is done by using for and while loops with the help of if else statements.   The HCF or GCD of two integers is the largest integer that can exactly divide both numbers…
Read more

Java Program to Display Fibonacci Series

Java Program to Display Fibonacci Series In this program, you’ll learn to display fibonacci series in Java using for and while loops. You’ll learn to display the series upto a specific term or a number. The Fibonacci series is a series where the next term is the sum of pervious two terms. The first two…
Read more

Java Program to Generate Multiplication Table

Java Program to Generate Multiplication Table In this program, you’ll learn to generate the multiplication table of a given number. This is done by using a for and a while loop in Java.   Example 1: Generate Multiplication Table using for loop public class MultiplicationTable { public static void main(String[] args) { int num =…
Read more

Java Program to Find Factorial of a Number

Java Program to Find Factorial of a Number In this program, you’ll learn to find the factorial of a number using for and while loop in Java. The factorial of a positive number n is given by: factorial of n (n!) = 1 * 2 * 3 * 4 * … * n Example 1:…
Read more

Java Program to Calculate the Sum of Natural Numbers

Java Program to Calculate the Sum of Natural Numbers In this program, you’ll learn to calculate the sum of natural numbers using for loop and while loop in Java. The positive numbers 1, 2, 3… are known as natural numbers and its sum is the result of all numbers starting from 1 to the given…
Read more

Java Program to Check Whether a Character is Alphabet or Not

Java Program to Check Whether a Character is Alphabet or Not In this program, you’ll learn to check whether a given character is an alphabet or not. This is done using an if else statement or a ternary operator in Java. Example: Java Program to Check Alphabet using if else public class Alphabet { public…
Read more

Java Program to Check Whether a Number is Positive or Negative

Java Program: Checking Whether a Number is Positive or Negative Java, as a versatile programming language, provides a straightforward way to check whether a number is positive or negative. In this comprehensive blog post, we’ll create a Java program to perform this check, offering both an explanation and a step-by-step guide. Additionally, we’ll provide example…
Read more