1 / 3

SEEM3460 Tutorial

SEEM3460 Tutorial. Arrays in Java. Arrays in Java. Initialization array1 = new SomeClass [ARRAY_SIZE]; array1 = {element1, element2, …}; Object as elements Example: Tunes.java + CDCollection.java + CD.java Array as parameter public void SomeMethod ( int [] arr ) {…}

shilah
Download Presentation

SEEM3460 Tutorial

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. SEEM3460 Tutorial Arrays in Java

  2. Arrays in Java • Initialization • array1 = newSomeClass[ARRAY_SIZE]; • array1 = {element1, element2, …}; • Object as elements • Example: Tunes.java + CDCollection.java + CD.java • Array as parameter • public void SomeMethod(int[] arr) {…} • Use System.arraycopy() and .length

  3. Exercise • Create an extra CD constructor for “Empty” • Create a class CDShelf with: • an integer variable called “rowcount” • an integer variable called “rowsize” • a two-dimensional array for holding “rowsize”x“rowcount” CDs • a constructor to fill shelf with “Empty” • a method to list all CDs of a row • a method to list all CDs of the shelf • a method to insert CD to specific position • a method to replace a row of CDs • a method to calculate row total price • a method to calculate shelf total price

More Related