There are two ways of accessing the classes stored in a package.
1. Using import keyword
We want to use a class in a number of places in a programe or we may like to use many of the classes contained in a package. We may achieve this as follows
import java.lang.*;
import java.lang.Scanner;
The first import statement imports all the classes and interfaces of language package into your java program. On the other hand the second import statement will import only the Scanner class into your java program.
2. Using package name and class name in full
If your not imported any of the package class using import keyword; then to use such classes in your program you need to follow the java naming conventions
java.io.Scanner scr =new java.io.Scanner(System.in);
0 comments :
Post a Comment
Note: only a member of this blog may post a comment.