package ch.claude_martin; import java.util.stream.IntStream; public final class SomeClass { private static final String FORMAT = "%s, %d, %s%n"; static final class Student { private final String name, gender; private final int age; // note that you should store the birth year instead public Student(String name, int age, String gender) { this.name = name; this.age = age; this.gender = gender; } public int getAge() { return age; } public String getName() { return name; } public String getGender() { return gender; } @Override public String toString() { return String.format(FORMAT, name, age, gender); } } public static void main(String[] args) { String[] names = { "Alice", "Bob", "Oscar" }; int[] ages = { 35, 65, 23 }; String[] gender = { "Cis Female", "Cis Male", "Other" }; assert names.length == ages.length && names.length == gender.length; IntStream.range(0, names.length).mapToObj(i -> new Student(names[i], ages[i], gender[i])) .forEach(System.out::print); } }