🗊 Презентация 5. Java collections and Generics. 3. Generics

Нажмите для полного просмотра!
5. Java collections and Generics. 3. Generics, слайд №1 5. Java collections and Generics. 3. Generics, слайд №2 5. Java collections and Generics. 3. Generics, слайд №3 5. Java collections and Generics. 3. Generics, слайд №4 5. Java collections and Generics. 3. Generics, слайд №5 5. Java collections and Generics. 3. Generics, слайд №6 5. Java collections and Generics. 3. Generics, слайд №7 5. Java collections and Generics. 3. Generics, слайд №8 5. Java collections and Generics. 3. Generics, слайд №9 5. Java collections and Generics. 3. Generics, слайд №10 5. Java collections and Generics. 3. Generics, слайд №11 5. Java collections and Generics. 3. Generics, слайд №12 5. Java collections and Generics. 3. Generics, слайд №13 5. Java collections and Generics. 3. Generics, слайд №14 5. Java collections and Generics. 3. Generics, слайд №15 5. Java collections and Generics. 3. Generics, слайд №16 5. Java collections and Generics. 3. Generics, слайд №17 5. Java collections and Generics. 3. Generics, слайд №18

Вы можете ознакомиться и скачать презентацию на тему 5. Java collections and Generics. 3. Generics. Доклад-сообщение содержит 18 слайдов. Презентации для любого класса можно скачать бесплатно. Если материал и наш сайт презентаций Mypresentation Вам понравились – поделитесь им с друзьями с помощью социальных кнопок и добавьте в закладки в своем браузере.

Слайды и текст этой презентации


Слайд 1


5. Collections and Generics 3. Generics
Описание слайда:
5. Collections and Generics 3. Generics

Слайд 2


Generics Basics JDK 5.0 introduces generics Generics allow you to abstract over types The most common examples are container types, such as those in...
Описание слайда:
Generics Basics JDK 5.0 introduces generics Generics allow you to abstract over types The most common examples are container types, such as those in the Collections hierarchy

Слайд 3


Generic Classes public class ClassName{ class body } Parametric type T can be used in the class body as usual type: private T a; public void set(T a)...
Описание слайда:
Generic Classes public class ClassName{ class body } Parametric type T can be used in the class body as usual type: private T a; public void set(T a) { this.a = a; } public T get() { return a; }

Слайд 4


Generic Objects You need to set a type in when creating an object of generic class: public class GenClass{ . . . . . } GenClass cInt = new GenClass();
Описание слайда:
Generic Objects You need to set a type in when creating an object of generic class: public class GenClass{ . . . . . } GenClass cInt = new GenClass();

Слайд 5


How Generics Work In the invocation all occurrences of the formal type parameter are replaced by the actual type argument The compiler can check the...
Описание слайда:
How Generics Work In the invocation all occurrences of the formal type parameter are replaced by the actual type argument The compiler can check the type correctness of the program at compile-time Primitive types cannot use as actual types

Слайд 6


Exercise. Print List Create a class with list of objects of an arbitrary given class with two methods: add for accumulation data in the list...
Описание слайда:
Exercise. Print List Create a class with list of objects of an arbitrary given class with two methods: add for accumulation data in the list printList with a boolean parameter to print odd or even elements of the list accordingly to parameter’s value

Слайд 7


Exercise. Print List See 531FirstGeneric project for the full text
Описание слайда:
Exercise. Print List See 531FirstGeneric project for the full text

Слайд 8


Generics Inheritance In general, if Sub is a subtype (subclass or subinterface) of Base, and G is some generic type declaration, it is not the case...
Описание слайда:
Generics Inheritance In general, if Sub is a subtype (subclass or subinterface) of Base, and G is some generic type declaration, it is not the case that G is a subtype of G

Слайд 9


Generic Interfaces Generic interfaces are similar to generic classes: public interface List{ void add(E x); Iterator iterator(); } public interface...
Описание слайда:
Generic Interfaces Generic interfaces are similar to generic classes: public interface List{ void add(E x); Iterator iterator(); } public interface Iterator{ E next(); boolean hasNext(); }

Слайд 10


Generic Methods Type parameters can also be declared within method and constructor signatures to create generic methods and generic constructors:...
Описание слайда:
Generic Methods Type parameters can also be declared within method and constructor signatures to create generic methods and generic constructors: public void inspect(U u){ . . . } Type inference feature allows you to invoke a generic method as you would an ordinary method, without specifying a type between angle brackets

Слайд 11


Generic Method Example class ArrayAlg { public static T getMiddle(T[] a) { return a[a.length / 2]; } } You can define generic methods both inside...
Описание слайда:
Generic Method Example class ArrayAlg { public static T getMiddle(T[] a) { return a[a.length / 2]; } } You can define generic methods both inside ordinary classes and inside generic classes

Слайд 12


Generic Method Call When you call a generic method, you can place the actual types, enclosed in angle brackets, before the method name: String[]...
Описание слайда:
Generic Method Call When you call a generic method, you can place the actual types, enclosed in angle brackets, before the method name: String[] names = { "John", "Q.", "Public" }; String middle = ArrayAlg.getMiddle(names);

Слайд 13


Wildcards What is the supertype of all kinds of collections? Collection is not such supertype due to generics inheritance rule Collection (pronounced...
Описание слайда:
Wildcards What is the supertype of all kinds of collections? Collection is not such supertype due to generics inheritance rule Collection (pronounced "collection of unknown"), that is, a collection whose element type matches anything

Слайд 14


Bounded Wildcards ? extends class_name ? stands for an unknown type that this unknown type is a subtype of class_name example: List
Описание слайда:
Bounded Wildcards ? extends class_name ? stands for an unknown type that this unknown type is a subtype of class_name example: List

Слайд 15


Bounded Wildcards Example public static double sumOfList(List
Описание слайда:
Bounded Wildcards Example public static double sumOfList(List

Слайд 16


Home Exercise 5.3.2 ( 1 of 2) Create TBill class that saves deal for buying treasury bills (nominal, price, amount of bills, maturity date) and...
Описание слайда:
Home Exercise 5.3.2 ( 1 of 2) Create TBill class that saves deal for buying treasury bills (nominal, price, amount of bills, maturity date) and calculating deal income as follows: income = (nominal – price) * amount

Слайд 17


Home Exercise 5.3.2 (2 of 2) Create DealAnalisys class that saves deals of any type (depo – single, barrier, month capitalization, TBill) Create...
Описание слайда:
Home Exercise 5.3.2 (2 of 2) Create DealAnalisys class that saves deals of any type (depo – single, barrier, month capitalization, TBill) Create compareIncome method that compares yield of the deal that saved in the class object and deal given as method’s parameter

Слайд 18


Manuals
Описание слайда:
Manuals



Похожие презентации
Mypresentation.ru
Загрузить презентацию