containers, packages - COP 3330 Slides 2/3 Topics Static...

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

View Full Document Right Arrow Icon
Slides 2/3 COP 3330
Background image of page 1

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

View Full DocumentRight Arrow Icon
Topics Static Packages Container objects
Background image of page 2
toString Java uses the toString method on objects to represent it as a string for purposes of string concatenation and such The toString method has the following signature: - public String toString() If you want to be able to print objects of your class to be able to be printed in a meaningful way, write this method in your class!
Background image of page 3

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

View Full DocumentRight Arrow Icon
Overloading Multiple methods (and constructors) with the same name can exist in the same class The formal parameters MUST be different Why do this? - Use different types of information to construct an object (e.g. Scanner constructors) - Perform similar operations (e.g. print() method in PrintStream)
Background image of page 4
Static Ordinarily, methods and fields are associated with objects The static modifier makes them associate with the class Example - See the class Math in java.lang
Background image of page 5

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

View Full DocumentRight Arrow Icon
Static To access a static member, use the class name instead of the object name - Example: foo = Integer.parseInt( 5 );
Background image of page 6
Packages Packages group related files Put a package statement at the top of the source file Put the files in directory with a name matching the package
Background image of page 7

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

View Full DocumentRight Arrow Icon
A Good Design … is Reusable This is a key aspect of object-oriented design
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/01/2010 for the course COP 3330 taught by Professor Staff during the Spring '08 term at University of Central Florida.

Page1 / 23

containers, packages - COP 3330 Slides 2/3 Topics Static...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online