How to take input from user in JAVA?
How to take input from user in
JAVA?
import java.util.*;
//entire util package is
imported
class scan
{
public static void main(String[] args)
{
int x,y;
Scanner in=new Scanner(System.in); //scanner is class name in
is object then constructor part(paramitrize),system.in
is paramiter.
//using new to allocate memory
System.out.println("enter two value(x,y)=");
x=in.nextInt(); //taking int value
y=in.nextInt();
System.out.println("x=" +x);
}
}
// nextLine: take string
input
// nextFloat: take float
input
Output:
enter two value(x,y)=
41
54
x=41
How to take input from user in JAVA?
Reviewed by Unknown
on
January 28, 2019
Rating:
Casino Restaurants Near Atlanta, GA - Mapyro
ReplyDeleteFind Casino 의정부 출장안마 Restaurants 김제 출장안마 near Atlanta, 거제 출장안마 GA 구미 출장안마 on Mapyro. 777 Casino Center Drive Cherokee, NC 28719. 광주광역 출장샵 (253) 688-8000.