Java Program to Find the Largest Among Three Numbers In this program, you’ll learn to find the largest among three numbers using if else and nested if..else statement in Java. Example 1: Find Largest Among three numbers using if..else statement public class Largest{ public static void main(String[] args){ double n1 = -4.5, n2 = …
Java Program to Check Whether an Alphabet is Vowel or Consonant In this program, you’ll learn to check whether an alphabet is a vowel or a consonant using if..else and switch statement in Java. Example 1: Check whether an alphabet is vowel or consonant using if..else statement public class VowelConsonant{ public static void main(String[] …
Java Program to Check Whether a Number is Even or Odd In this program, you’ll learn to check if a number entered by an user is even or odd. This will be done using if…else statement and ternary operator in Java. Example 1: Check whether a number is even or odd using if…else statement …
Java Program to Swap Two Numbers In this program, you’ll learn two techniques to swap two numbers in Java. The first one uses a temporary variable for swapping, while the second one doesn’t use any temporary variables. Example 1: Swap two numbers using temporary variable public class SwapNumbers{ public static void main(String[] args){ float …
Java Program to Compute Quotient and Remainder In this program, you’ll learn to compute quotient and remainder from the given dividend and divisor in Java. Example: Compute Quotient and Remainder public class QuotientRemainder{ public static void main(String[] args){ int dividend = 25, divisor = 4; int quotient = dividend / divisor; int remainder = …
Java Program to Find ASCII Value of a character In this program, you’ll learn to find and display the ASCII value of a character in Java. This is done using type-casting and normal variable assignment operations. Example: Find ASCII value of a character public class AsciiValue{ public static void main(String[] args){ char ch = …
Java Program to Multiply two Floating Point Numbers In this program, you’ll learn to multiply two floating point numbers in Java, store the result and display it on the screen. Example: Multiply Two Floating-Point Numbers public class MultiplyTwoNumbers{ public static void main(String[] args){ float first = 1.5f; float second = 2.0f; float product = …
Java Program to Add Two Integers In this program, you’ll learn to store and add two integer numbers in Java. After addition, the final sum is displayed on the screen. Example: Program to Add Two Integers public class AddTwoIntegers{ public static void main(String[] args){ int first = 10; int second = 20; System.out.println(“Enter two …
Java Program to Print an Integer (Entered by the User) In this program, you’ll learn to print a number entered by the user in Java. The integer is stored in a variable using System.in, and is displayed on the screen using System.out. Example: How to Print an Integer entered by an user import java.util.Scanner; public …
(Java programming Example for Beginners) Java ByteArrayInputStream Class In this tutorial, we will learn about Java ByteArrayInputStream and its methods with the help of examples. The ByteArrayInputStream class of the java.io package can be used to read an array of input data (in bytes). It extends the InputStream abstract class. Note: In ByteArrayInputStream, the input stream is created using the array of …