OUR STRUCTURE OF JAVA PROGRAMS Remember the structure of a Java program that we have been using so far? 1. Simplest: one class, one method: public class ____ { public static void main (String[] args) { ... } } 2. One class, multiple methods/functions: We then expanded the structure of a program by allowing multiple functions in a class. So, we now understand how to include multiple functions interacting one another in a class. public class ____ { public static --- () { ... } ... public static void main (String[] args) { ... } // Any number of functions of this form, // one of which is named 'main'. } We then expanded our horizon by learning more things that can go inside a function (method), i.e., conditionals (if...else...), looping (while, for), and arrays. We have been exercising our creativity by combing those things. I used ...... instead of ... to mean that. public class ____ { public static --- () { ...... } ... public static void main (String[] args) { ...... } // Any number of functions of this form, // one of which is named 'main'. } REMEMBER: Your programs MUST be in the STRUCTURE that I give you. Your Java program can NOT deviate from the above structure at this point, UNTIL I give you an updated structure! You cannot include a function definition inside another function definition because that is not allowed by the structure I give you here (and furthermore it is NOT legal in Java). You cannot use multiple classes to make up a Java program because MY STRUCTURE SO FAR DOES NOT ALLOW IT even though it is legal in Java. Soon, we will expand our structure to include such things! One exception: You may include zero or more import statements at the top of a Java file as we saw in Read.java. 3. One class, multiple methods, multiple static fields: There are times you will see that occasionally you will find static fields useful as you program. With static fields introduced into OUR STRUCTURE, the new structure of our Java programs looks like this now: public class ____ { // Any number of these (see StaticFields.java for an example) // private static = ; // Any number of static methods. // One of these functions is usually named 'main'. public static --- () { ...... } public static void main (String[] args) { ...... } } As I mentioned in StaticFields.java, please do not use static fields unless you are absolutely convinced that they are necessary and beneficial to use. If you are not sure, stay away from them. I will tell you more about them as we go. 4. Multiple classes, each class containing multiple methods, multiple static fields: Coming soon!