Templates for writing Java programs

Because it's not always obvious from the beginning how to write Java programs, here are templates for many of the types of program that you will have to write. Just copy the code and paste it into your editor (IDE). Later on more of this will make sense

For console-based programs

for Java programs that use the HSA2 graphics package (simpler than Swing)


You will have to change the name of the class in the template to whatever you plan on using.
Don't call all of your programs "App1.java"