In which package is scanner class included
Answers
Answered by
1
Hi there...
Rajdeep here!
Scanner class is included in package :
java.util
A package is a group of classes.
to include it in a class, write the following code:
import java.util.*
Rajdeep here!
Scanner class is included in package :
java.util
A package is a group of classes.
to include it in a class, write the following code:
import java.util.*
Answered by
1
Scanner is a class in java.util.package.
Example:
import java.util.Scanner;
class Add
{
public static void main(String args[])
{
int a,b,c;
System.out.print("Enter 1st number: ");
Scanner scan = new Scanner(System.in);
a = scan.nextInt();
System.out.println("Enter 2nd number: ");
b = scan.nextInt();
c = a + b;
System.out.println("The output is:" +c);
}
}
Hope this helps!
Example:
import java.util.Scanner;
class Add
{
public static void main(String args[])
{
int a,b,c;
System.out.print("Enter 1st number: ");
Scanner scan = new Scanner(System.in);
a = scan.nextInt();
System.out.println("Enter 2nd number: ");
b = scan.nextInt();
c = a + b;
System.out.println("The output is:" +c);
}
}
Hope this helps!
Similar questions
English,
7 months ago
Computer Science,
7 months ago
Chemistry,
1 year ago
Math,
1 year ago
India Languages,
1 year ago
English,
1 year ago
Biology,
1 year ago