Class odamlar: ismi, familyasi


Download 8.63 Kb.
Sana20.06.2023
Hajmi8.63 Kb.
#1636735
Bog'liq
9 amalioyt 3


class odamlar:
ismi,
familyasi,
yoshi

class talabalar:
bahosi

Array konteyneridan foydalanib
talabalar ro’yxatida ismi bo’yicha saralang.


import java.util.Arrays;
import java.util.Comparator;

class odamlar {
String ismi;
String familyasi;
int yoshi;
}

class talabalar extends odamlar {
int[] bahosi;

public talabalar(String ismi, String familyasi, int yoshi, int[] bahosi) {
this.ismi = ismi;
this.familyasi = familyasi;
this.yoshi = yoshi;
this.bahosi = bahosi;
}
}

public class Main {
public static void main(String[] args) {
talabalar[] talabalarRozyat = {
new talabalar("Mahliyo", "Rajabova", 18, new int[]{85, 90, 95}),
new talabalar("Shohjahon", "Rajabov", 19, new int[]{70, 80, 75})
};

Arrays.sort(talabalarRozyat, Comparator.comparingInt(talaba -> talaba.yoshi));

for (talabalar talaba : talabalarRozyat) {
System.out.println("Ismi: " + talaba.ismi);
System.out.println("Familyasi: " + talaba.familyasi);
System.out.println("Yoshi: " + talaba.yoshi);
System.out.println("Bahosi: " + Arrays.toString(talaba.bahosi));
System.out.println();
}
}
}
Download 8.63 Kb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling