Lecture05 - CS162: Introduction to Computer Science II...

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

View Full Document Right Arrow Icon
1 CS162: Introduction to Computer Science II Classes III
Background image of page 1

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

View Full DocumentRight Arrow Icon
2 Outline 1. Misc. items Clarification on overloading Layouts 2. Classes Inner classes Packages 3. Arrays
Background image of page 2
3 Clarification on Overloading Overloading: same method name for two or more methods of a class but different parameter lists Recall that the signature of each overloaded method must be unique The signature includes the number, type, and order of the parameters int add( int x, int y) Signature: int , int int add( double x, double y) Signature: double , double Because the signatures are unique, this is method overloading Example 1:
Background image of page 3

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

View Full DocumentRight Arrow Icon
4 Clarification on Overloading int add( int x, int y) Signature: int , int double add( int x, int y) Signature: int , int Because the signatures are not unique, this is not legal method overloading (compiler will complain) Example 2: int add( int x, double y) Signature: ? double add( double x, int y) Signature: ? Will this compile? Example 3:
Background image of page 4
5 Flow Layouts If you don’t specify a layout, Java uses a flow layout Flow layout: components arranged from left to right Starts a new row when there is no more room in the current row
Background image of page 5

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

View Full DocumentRight Arrow Icon
6 Grid Layout A grid layout arranges components in a grid with a fixed number of rows and columns Each component in the grid has the same size eg. GridLayout(3,2)
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 06/28/2009 for the course CS 161 taught by Professor Wallace during the Spring '08 term at Oregon State.

Page1 / 17

Lecture05 - CS162: Introduction to Computer Science II...

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

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