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

На нашем сайте вы можете скачать и просмотреть онлайн доклад-презентацию на тему 5. Java collections and Generics. 3. Generics абсолютно бесплатно. Урок-презентация на эту тему содержит всего 18 слайдов. Все материалы созданы в программе PowerPoint и имеют формат ppt или же pptx. Материалы и темы для презентаций взяты из открытых источников и загружены их авторами, за качество и достоверность информации в них администрация сайта не отвечает, все права принадлежат их создателям. Если вы нашли то, что искали, отблагодарите авторов - поделитесь ссылкой в социальных сетях, а наш сайт добавьте в закладки.
Презентации » Устройства и комплектующие » 5. Java collections and Generics. 3. Generics



Оцените!
Оцените презентацию от 1 до 5 баллов!
  • Тип файла:
    ppt / pptx (powerpoint)
  • Всего слайдов:
    18 слайдов
  • Для класса:
    1,2,3,4,5,6,7,8,9,10,11
  • Размер файла:
    107.00 kB
  • Просмотров:
    68
  • Скачиваний:
    0
  • Автор:
    неизвестен



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

№1 слайд
. Collections and Generics .
Содержание слайда: 5. Collections and Generics 3. Generics

№2 слайд
Generics Basics JDK .
Содержание слайда: 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
Содержание слайда: 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
Содержание слайда: Generic Objects You need to set a type in <> when creating an object of generic class: public class GenClass<Т>{ . . . . . } GenClass<Integer> cInt = new GenClass<Integer>();

№5 слайд
How Generics Work In 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
Содержание слайда: 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
Содержание слайда: Exercise. Print List See 531FirstGeneric project for the full text

№8 слайд
Generics Inheritance In
Содержание слайда: 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<Sub> is a subtype of G<Base>

№9 слайд
Generic Interfaces Generic
Содержание слайда: Generic Interfaces Generic interfaces are similar to generic classes: public interface List<E>{ void add(E x); Iterator<E> iterator(); }  public interface Iterator<E>{ E next(); boolean hasNext(); }

№10 слайд
Generic Methods Type
Содержание слайда: Generic Methods Type parameters can also be declared within method and constructor signatures to create generic methods and generic constructors: public <U> 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
Содержание слайда: Generic Method Example class ArrayAlg { public static <T> 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
Содержание слайда: 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.<String>getMiddle(names);

№13 слайд
Wildcards What is the
Содержание слайда: Wildcards What is the supertype of all kinds of collections? Collection<Object> 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
Содержание слайда: Bounded Wildcards ? extends class_name ? stands for an unknown type that this unknown type is a subtype of class_name example: List<? extends Shape> Code <? super class_name > would be read as "an unknown type that is a supertype of class_name, possibly class_name itself

№15 слайд
Bounded Wildcards Example
Содержание слайда: Bounded Wildcards Example public static double sumOfList(List<? extends Number> list) { double s = 0.0; for (Number n : list) s += n.doubleValue(); return s; }

№16 слайд
Home Exercise . . of Create
Содержание слайда: 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 . . of 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 http docs.oracle.com
Содержание слайда: Manuals http://docs.oracle.com/javase/tutorial/extra/generics/index.html

Скачать все slide презентации 5. Java collections and Generics. 3. Generics одним архивом: