March18

March18 - 'COMPARE TO METHOD useful to compare to objects...

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

View Full Document Right Arrow Icon
METHODS: to declare a method/hearder public String toString() header has to parts (visiblity modifier which is public. a return type which is String. the name of the method which is toString. and the parameter list which is () ). when static is bbepfre public its a shared method have a body reutn statement return namt+ "," + age; SCOPE: of a variable ex: class, instance, local local variable is a variable declared inside a method example of a local variable: public class Account{ String name; double balance; public void doubleBalance(){ int muliplier=2; blaance*=multiplier; } **once braket closes then the variable is finished and if you recall the doubleBlance then you have to reassign the vriable ***OVERWRITING overwriting a method: rewrithing a method becuase your older writing i already existed
Background image of page 1

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

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 'COMPARE TO' METHOD: useful to compare to objects starts off as public always public int compareTo(PlayingCard) hallmarks of good encapusation data private methods are public user or client cna only accsess through the methods private methods are helper methods so the user wont see it only we can see it and use it.does work for us and sves alot of typing visiblity modifires-public only avaible outside the class-privae only avialbe inside the class-"default"< this isnt actually typed, we just dont pt anything-protected<similar to private compareTo method: retuns an int if'this and pc are equivalent then 0 will be returned...
View Full Document

This note was uploaded on 03/21/2008 for the course CS 1301 taught by Professor Smith during the Spring '08 term at UGA.

Page1 / 2

March18 - 'COMPARE TO METHOD useful to compare to objects...

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

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