Created
December 3, 2021 10:37
-
-
Save AndreyKurilo/f7b137da8ad2c006d65c9bfbad6f65dc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.javarush.task.pro.task11.task1123; | |
import java.util.ArrayList; | |
import java.util.List; | |
public class UniversityGroup { | |
public List<String> students; | |
public UniversityGroup() { | |
students = new ArrayList<>(); | |
students.add("Сергей Фрединский"); | |
students.add("Виталий Правдивый"); | |
students.add("Максим Козыменко"); | |
students.add("Наталия Андрющенко"); | |
students.add("Ира Величенко"); | |
students.add("Николай Соболев"); | |
students.add("Снежана Слободенюк"); | |
} | |
ArrayList<String> studentsCopy = new ArrayList<String>(students); | |
public void exclude(String excludedStudent) { | |
for (String student : studentsCopy) { | |
if (student.equals(excludedStudent)) { | |
students.remove(student); | |
//students.removeIf(x -> x.equals(student)); | |
} | |
} | |
} | |
public static void main(String[] args) { | |
UniversityGroup universityGroup = new UniversityGroup(); | |
universityGroup.exclude("Виталий Правдивый"); | |
universityGroup.students.forEach(System.out::println); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment