Advertisement
Guest User

Untitled

a guest
Nov 12th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.33 KB | None | 0 0
  1. package ru.fciit.pdfgeneretor.networking.nettyapi;
  2.  
  3. public class ConstructorTest {
  4.  
  5.     int i;
  6.     String z;
  7.     boolean daunLiTi
  8.  
  9.     /**
  10.      * конструктор с параметром (параметризированный конструктор)
  11.      * на выходе получается объект в котором уже i = переданному
  12.      *
  13.      * @param i аннотация ломбока: @AllArgsConstructor
  14.      */
  15.     public ConstructorTest(int i) {
  16.         this.i = i;
  17.     }
  18.    
  19.     public ConstructorTest(int i, String z, boolean dolboeb) {
  20.         this.i = i;
  21.         this.z = z;
  22.         this.daunLiTi = dolboeb;
  23.     }
  24.  
  25.     private void test() {
  26.         //get instance of parametrized constructor
  27.         ConstructorTest test = new ConstructorTest(123);
  28.         //get instance of non-parametrized constructor;
  29.         ConstructorTest test2 = new ConstructorTest();
  30.         //get instance of multiparameter constructor
  31.         ConstructorTest dolboeb = new ConstructorTest(228, "ti dolboeb?", true);
  32.     }
  33.  
  34.     /**
  35.      * конструктор без параметров
  36.      * на выходе получается объект в котором i = 0
  37.      * аннотация ломбока @NoArgsConstructor
  38.      */
  39.     public ConstructorTest() {
  40.         i = 0;
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement