第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定

我的遍歷這出問題了 求解釋

package com.student;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class testSet {
?? ?
?? ?public List<Course> coursetwo;
?? ?public testSet(){
?? ??? ?coursetwo=new ArrayList<Course>();
?? ?}
?? ?/**
?? ? * @param args
?? ? */
?? ?public void SetAdd() {
?? ??? ?/**
?? ??? ? * 添加課程到coursetwo中
?? ??? ? */
?? ??? ?Course cr1=new Course("1","數據結構");
?? ??? ?coursetwo.add(cr1);
?? ??? ? Course cr2=new Course("2","Math");
?? ??? ? coursetwo.add(0,cr2);//在第0位置添加cr2
?? ??? ? Course [] cr3={new Course("3","語文"),new Course("4","English")};
?? ??? ? coursetwo.addAll(Arrays.asList(cr3));?? ??? ?
?? ??? ? Course [] cr4={new Course("5","大學語文"),new Course("6","離散數學")};
?? ??? ?? coursetwo.addAll(2, Arrays.asList(cr4));
?? ??? ?
?? ? }
?? ?public void ForEach(){
?? ??? ??? ?System.out.println("有以下課程可以選擇:");
?? ??? ??? ?for (Object obj :coursetwo) {
?? ??? ??? ??? ?Course cr=(Course)obj;
?? ??? ??? ??? ?System.out.println("課程-->"+cr.getId()+","+cr.getName());
?? ??? ??? ?}
?? ??? ?}
?? ?
?? ?public static void main(String[] args) {
?? ??? ?testSet ts=new testSet();
?? ??? ?ts.SetAdd();
?? ??? ?ts.ForEach();
?? ??? ?//創(chuàng)建學生對象?? ?
?? ??? ?Student student=new Student("1","Jack");
?? ??? ?
?? ??? ?System.out.println("歡迎"+student.getName()+"來選課!");
?? ??? ?Scanner console=new Scanner(System.in);
?? ??? ?for(int i =0;i<3;i++)//選課輸入要選的課程
?? ??? ?{
?? ??? ??? ?System.out.print("請輸入課程ID:\n");
?? ??? ??? ?String courseID=console.next();
?? ??? ??? ?for (Course cr :ts.coursetwo) {
?? ??? ??? ??? ?if(cr.getId().equals(courseID));
?? ??? ??? ??? ?{
?? ??? ??? ??? ?student.courses.add(cr);
?? ??? ??? ??? ?}
?? ??? ??? ??? ? continue;
?? ??? ??? ?}
?? ??? ?}
?? ??? ?System.out.println("添加的課程ID有:"+student.courses);
?? ??? ?//ts.SetForEach(student);
?? ?}
?? ?
?? ?public void SetForEach(Student student){
?? ??? ?System.out.println("總共選擇了"+student.courses.size()+"門課程!");
?? ??? ?for (Course cr : student.courses) {
?? ??? ??? ?System.out.println("選擇了課程:-->"+cr.getId()+":"+cr.getName());
?? ??? ?}
?? ?}
}

/*

*我遍歷選課后的課程,結果卻顯示的是全部課程

/*

正在回答

1 回答

main方法中的if后面為何有分號?而且也沒必要寫continue

0 回復 有任何疑惑可以回復我~
#1

NewserPctror 提問者

非常感謝!
2016-01-22 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

我的遍歷這出問題了 求解釋

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號