Advertisement
sergAccount

Untitled

Aug 23rd, 2020
951
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.90 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.spec.model;
  7.  
  8. public class Student {
  9.    
  10.     private String name;
  11.     private int age;
  12.  
  13.     public Student(String name, int age) {
  14.         this.name = name;
  15.         this.age = age;
  16.     }
  17.  
  18.     public String getName() {
  19.         return name;
  20.     }
  21.  
  22.     public void setName(String name) {
  23.         this.name = name;
  24.     }
  25.  
  26.     public int getAge() {
  27.         return age;
  28.     }
  29.  
  30.     public void setAge(int age) {
  31.         this.age = age;
  32.     }
  33.        
  34.     //переопределяем метод toString класса Object (method overriding - переопрделение метода)
  35.     @Override
  36.     public String toString(){
  37.         return "name=" + name + "_age=" + age;
  38.     }
  39. }
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement