which function accepts an integer by using scanner object
Answers
Answered by
1
Scanner 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, though not very efficient if you want an input method for scenarios where time is a constraint like in competitive programming.
To create an object
Answered by
0
public class StringToIntEx
{
public static void main (String[] args)
{
String s = "199";
try
{
int number = Integer.parseInt(s.trim());
System.out.println("number = " + number);
}
catch (NumberFormatException nfe)
{
System.out.println("NumberFormatException: " + nfe.getMessage());
}
}
}
Read more on Brainly.in - https://brainly.in/question/8241538#readmore
Similar questions