Skip to content

What You Should Know


Here’s what I expect you to know

Many have taken first semester java last semester. But, it’s easy to forget some details over a break. Some of you might have had the pre-req course a long time ago. What should you know, review, or re-learn? Here’s a good starting list.

Java Classes

public class Hello {

    // What's first in a class?

}

Java source code

  • How do file names relate to class names?
  • Where's my code?

Java packaging

package java112.analyzers;
  • What’s a package?
  • How does a package relate to the file system?

Interfaces

public interface Analyzer {

    // What goes here?

}

Instance Variables

  • What word will be at the start of every instance variable definition? Hint: not public

Class Variables (static variables)

  • How do you make a class variable?
  • Where do they go in your code?
  • What does that word, “static”, really mean?

Constants


Java code formatting

  • What’s your code supposed to look like?
  • Is it really that important? Yes.

Javadoc comments


Compiling java classes

  • Ugh, all that typing on the command line, there must be a better way. Sure is!

Running java applications


Java primitive data types

  • int
  • long
  • float
  • double
  • boolean

Java Object References

  • This one is really important!
// Can you tell me what every word and operator means here?
    String firstName = "Fred";
    Dog myDog = new Dog();

Instantiation of objects


Java Stack Traces

  Exception in thread "main" java.lang.NoClassDefFoundError: Hello
  Caused by: java.lang.ClassNotFoundException: Hello
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:248)

The special main() method.

// Can you type this from memory?
    public static void main(String[] arguments) {

    }
  • What's so special about this method?
  • What do we always do inside a main method?

Java Arrays

// Arrays of String

    // Create an array of Strings reference variable
    String[] stringArray;

    // Create an array of Strings that can hold 3 string 
    // and assign reference to reference variable
    stringArray = new String[3];

    // Assign the first element of the array to a string
    stringArray[0] = "Bill";

    // Assign the second element of the array to a string
    stringArray[1] = "Sue";

    // Assign the third element of the array to a string
    stringArray[2] = "Sue";

    // Loop through the array and output each string to the terminal
    for (index = 0; index < stringArray.length; index++) {
        System.out.println(stringArray[index]);
    }
  • What does stringArray.length mean?
  • What does new String[3] mean?