如何告诉程序循环或重新启动?

时间:2019-04-14 15:12:54

标签: java for-loop arraylist

我的计划旨在找到您理想的实习机会。它运行正常,但是如果用户找不到正确的实习机会,我想做一个循环来再次运行该程序。如果可能的话,我也想说:“没有可用的实习机会,但是这里是您选择的国家/地区提供的实习机会:”

if (foundInternships.size() > 0) {
        for (Internship foundInternship : foundInternships) {
            System.out.println("Congratulations! There is one available internship: " + foundInternship.getName());
        }
    } else {
        System.out.println("Sorry, there are no available internships. In order to keep you updated about other internship opportunities, please enter your email address");
        Scanner scanner;
        scanner = new Scanner (System.in);
        String mailadress= scanner.nextLine();
        System.out.println("Thank you! We will keep you updated");
    }



public ArrayList<Internship> find(Student me) {
    ArrayList<Internship> results = new ArrayList<Internship>();
    for (int i = 0; i < internships.size(); i = i + 1) {
        boolean isAMatch = me.isMatchingInternship(internships.get(i));

        if (isAMatch) {
            results.add(internships.get(i));
        }
    }
    return results;
}
public void add(Internship internship) {
    internships.add(internship);
}

0 个答案:

没有答案