Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Chapter 10 - Arrays. After you have read and studied this chapter, you should be able to: Manipulate a collection of data values, using an array; declare and use an array of primitive data types in writing a program; declare and use an array of objects in writing a program; define a method that accepts an array as its parameter and a method that returns an array; describe how a two-dimensional array is implemented as an array of arrays; manipulate a collection of objects, using lists and maps. | Chapter 10 Arrays 4th Ed Chapter 10 - ©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Objectives After you have read and studied this chapter, you should be able to Manipulate a collection of data values, using an array. Declare and use an array of primitive data types in writing a program. Declare and use an array of objects in writing a program Define a method that accepts an array as its parameter and a method that returns an array Describe how a two-dimensional array is implemented as an array of arrays Manipulate a collection of objects, using lists and maps 4th Ed Chapter 10 - ©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. We will cover the basic array processing in this lesson, manipulating arrays of primitive data types and objects. Array Basics An array is a collection of data values. If your program needs to deal with 100 integers, 500 Account objects, 365 real numbers, etc., you will use an array. In Java, an array is an indexed collection of data values of the same type. 4th Ed Chapter 10 - ©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Suppose you need to handle up to 300 Student objects in a program for maintaining a high school alumni list, would you use 300 variables? Suppose you need to process daily temperatures for a 12-month period in a science project, would you use 365 variables? You can, but would you? To manipulate a collection of data, we can use arrays. Arrays of Primitive Data Types Array Declaration [ ] //variation 1 [ ] //variation 2 Array Creation = new [ ] Example double[ ] rainfall; rainfall = new double[12]; Variation 1 double rainfall [ ]; rainfall = new double[12]; Variation 2 An array is like an object! 4th Ed Chapter 10 - ©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. As you can declare and create . | Chapter 10 Arrays 4th Ed Chapter 10 - ©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Objectives After you have read and studied this chapter, you should be able to Manipulate a collection of data values, using an array. Declare and use an array of primitive data types in writing a program. Declare and use an array of objects in writing a program Define a method that accepts an array as its parameter and a method that returns an array Describe how a two-dimensional array is implemented as an array of arrays Manipulate a collection of objects, using lists and maps 4th Ed Chapter 10 - ©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. We will cover the basic array processing in this lesson, manipulating arrays of primitive data types and objects. Array Basics An array is a collection of data values. If your program needs to deal with 100 integers, 500 Account objects, 365 real numbers, etc., you will use an array.