五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

Java:集合,ArrayList,請(qǐng)選擇你要執(zhí)行的功能1.查詢2.添加3.修改4.刪除,增刪改查

2020-03-12 18:54 作者:詩(shī)書畫唱  | 我要投稿

實(shí)現(xiàn)有功能“1.查詢2.添加3.修改4.刪除”的和ArrayList有關(guān)的程序


package a;


import java.util.ArrayList;

import java.util.Scanner;


public class lizi {


public static void main(String[] args) {


ArrayList<student> arr = new ArrayList<student>();


arr.add(new student(1, "詩(shī)名", '男', 95));


arr.add(new student(2, "書名", '男', 92));


arr.add(new student(3, "畫名", '男', 90));


arr.add(new student(4, "唱名", '男', 111));


arr.add(new student(5, "帥名", '男', 134));

while (true) {

System.out.println("請(qǐng)選擇你要執(zhí)行的功能1.查詢2.添加3.修改4.刪除");

Scanner s = new Scanner(System.in);

int num = s.nextInt();

if (num == 1) {

// 查詢:

System.out.println("執(zhí)行查詢功能");

for (student i : arr) {

System.out.println(i);

}

} else if (num == 2) {

// 添加:

System.out.println("已經(jīng)執(zhí)行添加“3, “張三”, '男', 88”功能,不信可執(zhí)行查詢功能");

arr.add(new student(3, "張三", '男', 88));

} else if (num == 3) {

// 修改:

System.out.println("執(zhí)行修改功能");

System.out.println("請(qǐng)輸入你要修改的學(xué)生的編號(hào)");

int bianhao = s.nextInt();

for (int i = 0; i < arr.size(); i++) {

if (bianhao == arr.get(i).bianhao) {

System.out.println("你要修改的成績(jī)?yōu)槎嗌?");

double d = s.nextDouble();

arr.get(i).ChengJi = d;

}

}

} else if (num == 4) {

// 刪除:

System.out.println("執(zhí)行刪除功能");

System.out.println("請(qǐng)輸入你要?jiǎng)h除的學(xué)生的編號(hào)");

int bianhao = s.nextInt();

for (int i = 0; i < arr.size(); i++) {

if (bianhao == arr.get(i).bianhao) {

arr.remove(arr.get(i));

}

}

System.out.println("刪除完畢");

}

}

}

}



class student {


int bianhao;


double ChengJi;


String name;


char sex;


public student(int bianhao, String name, char sex, double ChengJi) {


this.bianhao = bianhao;


this.name = name;


this.sex = sex;


this.ChengJi = ChengJi;


}


@Override

public String toString() {


return "編號(hào):" + bianhao + ",\t名字:" + name + ",\t性別:" + sex + ",\t成績(jī):"


+ ChengJi;


}


}


Java:集合,ArrayList,請(qǐng)選擇你要執(zhí)行的功能1.查詢2.添加3.修改4.刪除,增刪改查的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
安平县| 六盘水市| 从化市| 石城县| 枣强县| 宝丰县| 崇信县| 东兰县| 寿宁县| 桂平市| 绥江县| 乌海市| 建宁县| 临清市| 新余市| 长治市| 清新县| 杭州市| 河北区| 灵丘县| 疏附县| 和平区| 石景山区| 三明市| 且末县| 高淳县| 福鼎市| 东乡族自治县| 襄垣县| 静乐县| 临潭县| 武鸣县| 文水县| 平潭县| 大邑县| 通辽市| 东兴市| 拜城县| 新竹市| 上高县| 山东省|