I am trying to get the Team Roster and Coach class to show the output, however, when I run the program it doesn't produce the output. It only produces the first-class but after that, no output is shown.
public class Team {
public static void main(String[] args) {
String team_name = "Team Georgia";
System.out.println(team_name);
}
//Team Roster
public class Player {
public void main(String[] args) {
String[] first_name = {"Jack","Dave","Henry","John","David","Bob","Tony","Malcolm","Hiro","Jack","Jesus","Luck","Ben", "Benny", "Caboose", "Michael","Taylor","Mark","Hiroshida","Jack","Patric","Davin"};
String[] last_name = {"Le","lynth","Luther","Kendral","Larry","John","Dave","Grendal","Lee","Lyn","Susan","Solo","Holmes","Stark","Potter","Welma","Han","Smith","Solo","Weasly","Emma","Bones"};
String[] position = {"Front","Front","Front","Front","Side","Side","Side","Back","Back","Side","Front","Front","Front","Front","Side","Side","Side","Back","Back","Side","Mid","Mid"};
for ( int i = 0; i < first_name.length; i++ ) {
//System.out.print("First name: " + first_name[i]+ "\t\t" + " Last name: " + last_name[i] + "\t\t\t" + " Position: " + position[i] + "\n" );
System.out.println("First name: " + first_name[i]);
System.out.println("Last name: " + last_name[i]);
System.out.println("Position: " + position[i]);
}
}
}
//Coach
public class Coach {
public void main(String[] args) {
String[] first_name = {"Brown","Dave","Jack","King"};
String[] last_name = {"Jun","Jac","Frost","Kong"};
String[] title = {"Head Coach", "Assistant Coach", "Offensive Coordinator", "Defensive Coordinator"};
for ( int i = 0; i < first_name.length; i++ ) {
//System.out.print("First name: " + first_name[i]+ "\t\t" + " Last name: " + last_name[i] + "\t\t\t" + " Position: " + title[i] + "\n" );
System.out.println("First name: " + first_name[i]+ " Last name: " + last_name[i] + " Position: " + title[i]);
}
}
}
}
The classes Player and Coach are inner classes where as Team is the main Public class and your file will also be saved with name of Team class only (Team.java). So only the main() method of Team class is called, in order to run the main methods of nested class also you need to class them separately.
Since your nested classes are not static, to call the main() method of nested class you first need to make an object of Team class then reference to other nested class object and call main method from that object.
For example,