Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Chapter 10 introduce to Arrays and collections. 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. | ©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 10 - Chapter 10 Arrays and Collections Animated Version Introduction to OOP with Java 4th Ed, C. Thomas Wu © The McGraw-Hill Companies, Inc. 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 Intro to OOP with Java, C. Thomas Wu ©The McGraw-Hill Companies, Inc. We will cover the basic array processing in this lesson, manipulating arrays of primitive data types and objects. ©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 10 - 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. Intro to OOP with Java, C. Thomas Wu ©The McGraw-Hill Companies, Inc. 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. ©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 10 - Arrays of Primitive Data Types Array Declaration [ ] //variation 1 [ ] //variation 2 Array Creation = new [ ] Example double[ ] rainfall; rainfall = new . | ©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 10 - Chapter 10 Arrays and Collections Animated Version Introduction to OOP with Java 4th Ed, C. Thomas Wu © The McGraw-Hill Companies, Inc. 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 Intro to OOP with Java, C. Thomas Wu ©The McGraw-Hill Companies, Inc. We will cover the basic array processing in this lesson, manipulating arrays of primitive data types and objects. ©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. .