1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
public class Osoba { public String imie; public int id; public static int count = 1; public Osoba(String imie) { this.imie = imie; id = count; count++; } public static void main(String[] args) { Osoba o1 = new Osoba("Piotr"); Osoba o2 = new Osoba("Pawel"); Osoba o3 = new Osoba("Ola"); System.out.println("Osoba " + o1.imie + " ma numer: " + o1.id); System.out.println("Osoba " + o2.imie + " ma numer: " + o2.id); System.out.println("Osoba " + o3.imie + " ma numer: " + o3.id); } } |