Last active
January 21, 2016 19:05
-
-
Save AnatoliiStepaniuk/b8da10f4075eb9efdaae 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.rubaka.students_arraylist; | |
import java.util.ArrayList; | |
import java.util.List; | |
public class Main | |
{ | |
public static void main( String[] args ) | |
{ | |
List<Student> students = new ArrayList<>(); | |
Student student1 = new Student(); | |
student1.setFirstName( "Ivanov" ); | |
student1.setLastName( "123" ); | |
students.add( student1 ); | |
students.add( new Student("Petrov", "{Petr") ); | |
students.add( new Student("Petrov2", "{Petr2") ); | |
students.add( new Student("Petrov3", "{Petr3") ); | |
students.add( new Student("Petrov4", "{Petr4") ); | |
students.add( new Student("Petrov5", "{Petr5") ); | |
for(int i = 0; i < students.size(); i++){ | |
System.out.println( students.get( i ).getFirstName() + " " + students.get( i ).getLastName() ); | |
} | |
for(Student student : students) | |
System.out.println(student.getFirstName() + " " + student.getLastName()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment