{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Recitation4 - Recitation 4 Classes public class Student cfw...

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

View Full Document Right Arrow Icon
Recitation 4
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
Classes public class Student { }
Background image of page 2
Data Members public class Student { private String name; public String id; }
Background image of page 3

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

View Full Document Right Arrow Icon
Data Members private String variableName; public String variableName; Public means the variable can be accessed outside of its own class Private means the variable is not accessible outside of its own class
Background image of page 4
Methods public class Student { String id; public void setID(String studentID){ id = studentID; } }
Background image of page 5

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

View Full Document Right Arrow Icon
Methods public void setID(String studentID) Public or Private Return type: void Name method: setID Argument: String studentID
Background image of page 6
Methods Public class Student{ String id; public String getID(){ return id; } } If the return type is not void, must have a return statement
Background image of page 7

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

View Full Document Right Arrow Icon
Class Constructor public class Student{ public String id; public Student(String studentID){ id = studentID; } }
Background image of page 8
Class Constructor Method defined within class Not necessary to define one, a default one is created if no constructor is found More than one constructor allowed, but each one must have a different set of arguments
Background image of page 9

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

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

{[ snackBarMessage ]}