Let's talk about what we just coded.

The line "public class Person" is called the class header. Let's drill into it.

  • public indicates that this class is public, and may be used by other objects
  • The keyword class tells the compiler that we are defining a class
  • Person is the name of the class we are defining

Notes:

  • "public" and "class" are called Java keywords and must be spelled exactly as shown (including case)
  • "Person" is the name of our class.
  • We generally will code our classes as "public", unless otherwise noted

When we write code we are effectively talking to the Java compiler, e.g. telling it "this is public", etc
1
public
2
class
3
Person { }