Importing Classes and Packages The first two lines of the following listing import two classes used in the applet: Applet and Graphics . import java.applet.Applet; import java.awt.Graphics; public class HelloWorld extends Applet { public void paint(Graphics g) { g.drawString("Hello world!", 50, 25); } } If you removed the first two lines, the applet could still compile and run, but only if you changed the rest of the code like this: public class HelloWorld extends java.applet. Applet { public void paint( java.awt. Graphics g) { g.drawString("Hello world!", 50, 25); } } As you can see, importing the Applet and Graphics classes lets the program refer to them later without any prefixes. The java.applet. and java.awt. prefixes tell the compiler which packages it should search for the Applet and Graphics classes. Both the java.applet and java.awt packages are part of the core Java API -- API that every Ja...
This blogs is to help the students for acquiring knowledge and wisdom.