Java Input, Output and token operation
Input ( Scanner class )
Scanner is a pre-defined class in java which is available in java.util package. it is used to get input in runtime.
Scanner sc = new Scanner(System.in) int a = sc.nextInt();Scanner class methods:
nextLine(); // String nextInt(); // integer nextFloat(); // float type nextBoolean(); // true or false nextDouble(); // double typeToken
Token is the smallest element of a program that is identified by a complier. Every java statement and expression are created using tokens
- keywords
- identifiers
- operator
- separator
- literal
In this program:class HelloWorld {public static void main(String[] args) {int a =10;int b = 20;int c = a + b;System.out.println(c);}}
i. keyword : int, static, void
ii. identifire : variable name, method name, class name, package name
iii. Operator : (+ - * / % && || )
iv. Sepreator : ( ; , . : ( ) { } )
Post a Comment