Library classes
Library classes
byte Byte
short Short
int Integer
long Long
float Float
double Double
char Character
boolean Boolean
Boxing and Unboxing:
Scanner Class: The class that allows to input or read primitive data types
and string is known as Scanner Class. It can be used to get input from
InputStream. The scanner class is a part of java.util package. This class
has many built functions. To use Scanner class java.util package must be
imported. Syntax:
import java.util.*; or import java.util.Scanner;
The following syntax declares Scanner class and creates its object.
Scanner sc= new Scanner(System.in);
Here Scanner is a class, sc is an object name, System.in an InputStream.
Functions of Scanner Class:
nextInt() This function is used to input an
integer value.
nextLong() This function is used to input a long
integer value.
nextFloat() This function is used to input a
float value.
nextDouble() This function is used to input a
double value.
next() This function is used to input a
single word without space.