{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

class definition

class definition - The class definition We write our first...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
The class definition We write our first Java class, in the upper right pane of DrJava. This class definition will describe the components that are placed in each manilla folder, or object, of the class. We start by putting a comment that indicates what each instance of the class has in it. /** An instance is like a JFrame but has two more methods */ We then type public , which means that this class can be referenced from anywhere else; class , which means that we are writing a new class definition; a name for the class, we choose Demo ; and an opening and closing brace. The opening brace goes on the same line with the name of the class. The words public and class appear in blue, because they are keywords and cannot be used as identifiers —as names of variables, methods, or classes. Instances of class Demo have essentially nothing in them, because we haven’t declared any components. We save this class definition, by clicking button Save . A navigation window opens, and we navigate to where we want to place the program, create a new folder, and save the program with the same name as the class.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}