Java Scanner class | Java Scanner demo program

Scanner Class In Java:

Scanner class is used to collect user input. To create an object of Scanner class first we need to import java.util.Scanner class and we need to pass predefined object System.in.

  •  To read the values of certain data types, Syntax is: nextDatatype() 

Write a java program to swap two numbers

Ex: Write a java program to swap two numbers. How to write a java program to swap two numbers using temp variable. java program to swap two numbers using temp variable.

Write a Java Program to Print Given Number is Even or Odd

In this example, You will learn how to print given number is even or odd using java. In below program we will use if-else statements to check given number is even or odd.