[Skip to Body]
Primary:
[Front Door]
[Current]
[Glance]
-
[Honesty]
[Links]
[Syllabus]
Groupings:
[EBoards]
[Examples]
[Exams]
[Handouts]
[Homework]
[Labs]
[Outlines]
[Readings]
[Reference]
Misc:
[SamR]
[Java 1.4.2 API]
[EIJ]
[CS152 2000F]
[CS153 2004S]
Back to An Introduction to Java (2). On to Objects and Classes.
Held: Friday, 3 September 2004
Summary: Today we begin the study of classes, the primary building blocks of Java programs. Classes not only provide the main method, but also serve as templates for creating new objects.
Related Pages:
import ClassWhoseNameYouDontWantToTypeInFull; /** * A helpful introductory comment that describes the class. */ public class ClassName { // Field declarations // Constructors // Methods } // class ClassName
public
). + The type of value the method returns. You can use
void
when a method doesn't return anything.
String name;
anywherein the class; variables are available only in the method they are declared in.
this
.
public String getName() { return this.name; } // getName() public void setName(String newName) { this.name = newName; } // setName(String)
main
method. You can
think of the main
method as a combination of the script
and directory of a play. This method creates the objects that form
the initial actorsof the play that is your program. It then tells them what to do.
pen.print(vec.getX()); pen.print(",") pen.println(vec.getY());
vec.printWith(pen);
researchAssistant.print(pen, vec);
Back to An Introduction to Java (2). On to Objects and Classes.
[Skip to Body]
Primary:
[Front Door]
[Current]
[Glance]
-
[Honesty]
[Links]
[Syllabus]
Groupings:
[EBoards]
[Examples]
[Exams]
[Handouts]
[Homework]
[Labs]
[Outlines]
[Readings]
[Reference]
Misc:
[SamR]
[Java 1.4.2 API]
[EIJ]
[CS152 2000F]
[CS153 2004S]
Disclaimer:
I usually create these pages on the fly
, which means that I rarely
proofread them and they may contain bad grammar and incorrect details.
It also means that I tend to update them regularly (see the history for
more details). Feel free to contact me with any suggestions for changes.
This document was generated by
Siteweaver on Wed Dec 8 10:37:07 2004.
The source to the document was last modified on Fri Sep 3 10:53:50 2004.
This document may be found at http://www.cs.grinnell.edu/~rebelsky/Courses/CS152/2004F/Outlines/outline.05.html
.
You may wish to
validate this document's HTML
;
;
Check with Bobby