Building an Application
Okay, so now let's look at the rest of the Test class because the Test class is pretty special.
The Test class is actually a very small Java Application that can be compiled and executed!
Here is the code again...
public class Test
{
public static void main(String[] args)
{
Announcer a = new Announcer();
a.printAnnouncement();
}
}
You should already be comfortable with the definition of the class from the last section.
You should also be familiar with the contents of the main() method since we just discussed it.
But what is the main() method and why is there no constructor for Test?
Well, the main() method is a very special method because it works without an instantiation of the class.
It does this because the main() method is static.
static is a keyword that, when applied to classes means that no instantiation is necessary in order to run it.
Notice also that the main method may take an array of strings as arguments.
This is used so that we can pass information to our application from the command line if we want.
However, in this case we won't be passing any arguments.
NEXT
Selena Sol contributes to the JavaBoutique's Introduction to Java. Selena curently works for Barclays Capital in London, one of the leading global investment banks in Europe and has worked as a software developer for the National Center for Human Genome research, Microline Software, Neuron Data, and Electric Eye in Singapore. Selena is perhaps best-known for creating the Public Domain Web Script Archive (Extropia) and writing several books on Web Programming (Perl, CGI, Java).
Email: selena@extropia.com
New on the Java Boutique:
New Review:
Time Management Made Easy with the Quartz Enterprise Job Scheduler
Why not just use the Java timer API? This open source scheduling
API boasts simplicity, ease-of-integration, a well-rounded feature
set, and it's free!
New Applet:
Reverse Complement
Reverse Complement is a simple applet that converts DNA or RNA
sequences into three useful formats.
Elsewhere on internet.com:
WebDeveloper Java
Lots of Java information on webdeveloper.com
WDVL Java
Thorough Java resource at the Web Developer's Virtual Library.
ScriptSearch Java
Hundreds of free Java code files to download.
jGuru: Your View of the Java Universe
Customizable portal with online training, FAQs, regular news updates, and tutorials.
|