Importing libraries using different ways

package com.company;
import java.util.Scanner;//importing only Scanner ibrary
import java.util.*; //importing all the libraries
public class importingLIBRARIES {
public static void main(String[] args) {
Scanner s= new Scanner(System.in);
int a= s.nextInt();
System.out.println("using Scanner function get value "+ a);
//user can also use library function like this
java.util.Scanner x = new java.util.Scanner(System.in);
int t= x.nextInt();
System.out.println("using import line in program to get value "+t );
Random r= new Random();
int y=r.nextInt(10);
System.out.println("using * import style to get random value "+y);
}
}


Output




 

No comments:

Post a Comment

    Hello, I'm Vishal Rana  I'm 19 years old  I live in Himachal Pradesh and  currently I'm studying in college for my UG degree...