COMP 110 More Arrays - PowerPoint PPT Presentation

1 / 18
About This Presentation
Title:

COMP 110 More Arrays

Description:

Due April 23 (that's 3 weeks!) This is a HARD program. Start ... public void myMethod(int, Smiley) this.myMethod(intArray[2], sArray[0]); Read FAQ on p. 440 ... – PowerPoint PPT presentation

Number of Views:42
Avg rating:3.0/5.0
Slides: 19
Provided by: michele9
Category:
Tags: comp | arrays | more | smiley

less

Transcript and Presenter's Notes

Title: COMP 110 More Arrays


1
COMP 110More Arrays
  • Tabitha Peck M.S.
  • April 2, 2008
  • MWF 3-350 pm
  • Philips 367

2
Announcements
  • Program 4
  • Due April 23 (thats 3 weeks!)
  • This is a HARD program
  • Start early
  • Start early
  • Start early

3
Program 4 Demo
4
Questions?
5
Today in COMP 110
  • More about arrays
  • Info for program 4

6
You have Seen Arrays Before
  • import java.util. public class Arguments
    public static void main(String
    args) for(int i 0 i lt
    args.length i)
    System.out.println(argsi)
  • Build ? Run Arguments

7
Arrays in ClassesInstance Variable
  • private int intArray
  • public static void setLength(int len)
  • intArray new intlen

8
Array of Classes
  • Smiley smile new Smiley3

9
Arrays as Arguments
  • public void changeArray(int a)
  • int len a.length
  • alen 25

25
10
Arrays as Return Types
  • public float buildArray(int len)
  • float ret new floatlen
  • for(int i 0 i lt len i)
  • reti i1.5
  • return ret

11
Types
  • int array new int3
  • array0 5
  • array1 6
  • array2 8
  • What is the type of array?
  • What is the type of array2?

12
Indexed variables as arguments
  • public void myMethod(int, Smiley)
  • this.myMethod(intArray2, sArray0)
  • Read FAQ on p. 440

Cannot change value
Can change smiley
13
Swap
14
2D Arrays
  • Int twoD new int34

column
row
15
Selection Sort
  • For (index 0 index lt length index)
  • Find index of smallest value of array from index
    to length
  • Swap values of current index and the index with
    the smallest value

16
Selection Sort
17
Bubble Sort
18
Friday
  • Lab 7
  • Sorting Algorithms
Write a Comment
User Comments (0)
About PowerShow.com