ITEC 1620 Lecture 17: 1620_lecture_17_slides
29 views29 pages
17 Oct 2015
School
Department
Course
Professor
Document Summary
A table is a large collection of data logically/sequentially ordered. Want easy access to each data element. Note: each data element has same datatypeyp. Starting with a table index, would like to access the data ld lik h d i h bl i d i. S element public int accesstableitem (int index) public int accesstableitem (int index) if (index == 1) return data1;; else if (index == 2) return data2; else if (index == 3) return data3; If else if"s are time consuming. Must know number of elements to set up access method. Different access method needed for tables of different size. Better access method use offsets to directly access the data block/table datadata. Data block/table is referred to by a y reference. Table of n elements will have offsets numbered from 0 to n-1 numbered from 0 to n 1. In java, arrays are implemented as objects objects. Array syntax has conventions which y y predate java.