tailieunhanh - Lecture Java™ How to Program (8/e) - Chapter 20: Generic collections

In this chapter, students will be able to: To create generic methods that perform identical tasks on arguments of different types; to create a generic Stack class that can be used to store objects of any class or interface type; to understand how to overload generic methods with non-generic methods or with other generic methods;. | 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. (C) 2010 Pearson Education, Inc. All rights reserved. Java collections framework prebuilt data structures interfaces and methods for manipulating those data structures (C) 2010 Pearson Education, Inc. All rights reserved. A collection is a data structure—actually, an object—that can hold references to other objects. Usually, collections contain references to objects that are all of the same type. Figure lists some of the interfaces of the collections framework. Package . (C) 2010 Pearson Education, Inc. All rights reserved. (C) 2010 Pearson Education, Inc. All rights reserved. Each primitive type has a corresponding type-wrapper class (in package ). Boolean, Byte, Character, Double, Float, Integer, Long and Short. Each type-wrapper class enables you . | 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. (C) 2010 Pearson Education, Inc. All rights reserved. Java collections framework prebuilt data structures interfaces and methods for manipulating those data structures (C) 2010 Pearson Education, Inc. All rights reserved. A collection is a data structure—actually, an object—that can hold references to other objects. Usually, collections contain references to objects that are all of the same type. Figure lists some of the interfaces of the collections framework. Package . (C) 2010 Pearson Education, Inc. All rights reserved. (C) 2010 Pearson Education, Inc. All rights reserved. Each primitive type has a corresponding type-wrapper class (in package ). Boolean, Byte, Character, Double, Float, Integer, Long and Short. Each type-wrapper class enables you to manipulate primitive-type values as objects. Collections cannot manipulate variables of primitive types. They can manipulate objects of the type-wrapper classes, because every class ultimately derives from Object. (C) 2010 Pearson Education, Inc. All rights reserved. Each of the numeric type-wrapper classes—Byte, Short, Integer, Long, Float and Double—extends class Number. The type-wrapper classes are final classes, so you cannot extend them. Primitive types do not have methods, so the methods related to a primitive type are located in the corresponding type-wrapper class. (C) 2010 Pearson Education, Inc. All rights reserved. A boxing conversion converts a value of a primitive type to an object of the corresponding type-wrapper class. An unboxing conversion converts an object of a type-wrapper class to a value of the corresponding primitive type. These conversions can be performed automatically (called autoboxing and auto-unboxing). Example: // create integerArray Integer[]

TỪ KHÓA LIÊN QUAN