what is the difference between input using scanner and method parameters plz tell fast
Answers
Answer:
Scanner class is a prewritten class in java.util package and scanner methods are the functions written in scanner class which can be used by using object reference of Scanner class.
Example:
Scanner sc = new Scanner(System.in);
// String input
String name = sc.nextLine();
some of the scanner methods are below;
public String nextLine()
it moves the scanner position to the next line and returns the value as a string.
public byte nextByte()
it scans the next token as a byte.
public short nextShort()
it scans the next token as a short value.
public int nextInt()
it scans the next token as an int value.
public long nextLong()
it scans the next token as a long value.
public float nextFloat()
it scans the next token as a float value.
public double nextDouble()
it scans the next token as a double value.