Lecture Java™ How to Program (8/e) - Chapter 7: Arrays and ArrayLists

After reading the material in this chapter, you should be able to: What arrays are; to use arrays to store data in and retrieve data from lists and tables of values; to declare an array, initialize an array and refer to individual elements of an array; to use the enhanced for statement to iterate through arrays; to pass arrays to methods; to declare and manipulate multidimensional arrays;. | Java™ How to Program, 8/e (C) 2010 Pearson Education, Inc. All rights reserved. (C) 2010 Pearson Education, Inc. All rights reserved. (C) 2010 Pearson Education, Inc. All rights reserved. Data structures Collections of related data items. Discussed in depth in Chapters 20–22. Arrays Data structures consisting of related data items of the same type. Make it convenient to process related groups of values. Remain the same length once they are created. Enhanced for statement for iterating over an array or collection of data items. Variable-length argument lists Can create methods are with varying numbers of arguments. Process command-line arguments in method main. (C) 2010 Pearson Education, Inc. All rights reserved. Common array manipulations with static methods of class Arrays from the package. ArrayList collection Similar to arrays Dynamic resizing They automatically increase their size at execution time to accommodate additional elements (C) 2010 Pearson . | Java™ How to Program, 8/e (C) 2010 Pearson Education, Inc. All rights reserved. (C) 2010 Pearson Education, Inc. All rights reserved. (C) 2010 Pearson Education, Inc. All rights reserved. Data structures Collections of related data items. Discussed in depth in Chapters 20–22. Arrays Data structures consisting of related data items of the same type. Make it convenient to process related groups of values. Remain the same length once they are created. Enhanced for statement for iterating over an array or collection of data items. Variable-length argument lists Can create methods are with varying numbers of arguments. Process command-line arguments in method main. (C) 2010 Pearson Education, Inc. All rights reserved. Common array manipulations with static methods of class Arrays from the package. ArrayList collection Similar to arrays Dynamic resizing They automatically increase their size at execution time to accommodate additional elements (C) 2010 Pearson Education, Inc. All rights reserved. Array Group of variables (called elements) containing values of the same type. Arrays are objects so they are reference types. Elements can be either primitive or reference types. Refer to a particular element in an array Use the element’s index. Array-access expression—the name of the array followed by the index of the particular element in square brackets, []. The first element in every array has index zero. The highest index in an array is one less than the number of elements in the array. Array names follow the same conventions as other variable names. (C) 2010 Pearson Education, Inc. All rights reserved. (C) 2010 Pearson Education, Inc. All rights reserved. An index must be a nonnegative integer. Can use an expression as an index. An indexed array name is an array-access expression. Can be used on the left side of an assignment to place a new value into an array element. Every array object knows its own length and stores it in a length

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.