+ 1
How to use import in programs ? plz explain it!
Import
3 odpowiedzi
+ 1
import is a keyword that is used to import packages in programs
eg:- a user want to take input from user by keyboard so he import package
import java.io*;
+ 1
import is a keyword in java which means to import something e.g to take input from user you have to import java.util.Scanner;
0
Packages are collections of useful functions a programmer might like to use instead of making their own. To use a package they import it into the program using the keyword 'import', then they type the package itself.
Packages may contain many useful functions so it may be necessary to only reference one import item. The coder would then type in the import keyword then the name of the tool they wish to use. However if a coder wished to import the entire package they can use a * to reference all tools in that package.
for example. below might be the full package name for a tool.
import java.awt.2dgraphics.
Below would reference all packages in the Java awt library.
import java.awt.*
The * means look for and use all items in the package.
Java import statements are stated at the beginning of a class file.(I haven't done java in 5 years so these package names are likely wrong.)