Advertisement
sergAccount

Untitled

Jul 17th, 2021
1,123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.75 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package com.mycompany.ex22;
  7.  
  8. public class Main {
  9.     //
  10.     public static void main(String[] args) {
  11.         // Обобщения (generics) (обобщенные классы (универсальные классы))        
  12.         // <T> - синтаксис, где T - тип  
  13.         // Holder<String> - используем Holder который хранит String
  14.         Holder<String> h1 = new Holder<>();
  15.         String s = h1.getValue();
  16.         //
  17.         Holder<Person> h2 = new Holder<>();        
  18.         Person p = h2.getValue();
  19.     }
  20. }
  21.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement