2.
Using Scanner class
● It is a class in java. util package
● used for obtaining the input of the primitive types like int, double, etc. and
strings.
● It is the easiest way to read input in a Java program
Using console class
● The Java Console class is be used to get input from console(command
line).
● It provides methods to read texts and passwords.
● If you read password using Console class, it will not be displayed to the
user.
Example
EXAMPLE
java.io.Serializable interface
Serializable is a marker interface (has no data member and method). It is used to
"mark" Java classes so that the objects of these classes may get a certain capability.
import java.io.Serializable;
public class Student implements Serializable{
int id;
String name;
public Student(int id, String name) {
this.id = id;
this.name = name; } }
In the above example, Student class implements Serializable interface. Now its objects
can be converted into stream.