Advertisement
Guest User

Untitled

a guest
Nov 12th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.73 KB | None | 0 0
  1. package test;
  2.  
  3. public class ConstructorTest {
  4.    
  5.     int i;
  6.  
  7.     /**
  8.      * конструктор с параметром (параметризированный конструктор)
  9.      * на выходе получается объект в котором уже i = переданному
  10.      * @param i
  11.      * аннотация ломбока: @AllArgsConstructor
  12.      */
  13.     public ConstructorTest(int i) {
  14.         this.i = i;
  15.     }
  16.  
  17.     /**
  18.      * конструктор без параметров
  19.      * на выходе получается объект в котором i = 0
  20.      * аннотация ломбока @NoArgsConstructor
  21.      */
  22.     public ConstructorTest() {
  23.         i = 0;
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement