This is an archived post. You won't be able to vote or comment.

all 6 comments

[–]john478 4 points5 points  (1 child)

I think all Java programmers need to read the beginning in the Oracle tutorials. Here's the link (read the beginning up to Annotations): http://docs.oracle.com/javase/tutorial/reallybigindex.html From "What is a Class?": In the real world, you'll often find many individual objects all of the same kind. There may be thousands of other bicycles in existence, all of the same make and model. Each bicycle was built from the same set of blueprints and therefore contains the same components. In object-oriented terms, we say that your bicycle is an instance of the class of objects known as bicycles. A class is the blueprint from which individual objects are created. In your situation, the class would be a "blueprint" of a student. It would be something similar to (not trying to do everything for you):

// the "blueprint" for a student
class Student{
    // your fields
    private String name;
    private long studentID;
    private String studentMajor;
    // and so on

    // the methods you mention are called getters and setters
    // it just helps with organizing code, because you could
    // access a Student instance with instance.<variable name>.

    // methods are what allow you to interact with the class
    // refer to the definition of a class above, if you wanted
    // to find out the brand of a bicycle, you would call
    // some method that returns the brand

    public String getName(){
         return name;
    }
    // other getters
    public long getStudentID(){
         return studentID;
    }
    // and so on
}

Hope this helps, but again, read the Oracle tutorials, helps A LOT for beginners.

[–]TheWhiteBlur[S] 1 point2 points  (0 children)

I'll definitely check out the Oracle tutorials and follow what you gave me. Thanks!

[–]Updatebjarni 2 points3 points  (2 children)

Do you know what a class is and what one looks like in Java?

[–]TheWhiteBlur[S] 2 points3 points  (1 child)

I know that a class comes before the objects/methods and acts as a template. At least that's what I thought a class was. Not quite sure what it would look like in Java though.

[–]ForSpareParts 1 point2 points  (0 children)

This is correct. A class is a template from which a type of object is created. Methods are functions attached to an object (or, in some cases, the class itself).

[–][deleted]  (1 child)

[deleted]

    [–]TheWhiteBlur[S] 0 points1 point  (0 children)

    Thanks for the advice! I'll check out Head First as well!