void acceptNames() {
for(int i = 1; i <= N; i++) {
System.out.print("TEAM "+i+": ");
names[i-1] = sc.nextLine();
sizes[i-1] = names[i-1].length();
}
maxSize = 0;
for(int i = 0; i < N; i++) {
for(int j = 0; j < N; j++) {
if(sizes[i] > sizes[j]) {
maxSize = sizes[i];
}
else {
maxSize = sizes[j];
}
}
}
System.out.println(maxSize);
}
Im getting the output for N = 4 as:
N = 4 TEAM 1: TEAM 2: this is just an example TEAM 3: heloo TEAM 4: foo bar 7 *
please help me cause i am not able to figure out why i am getting team 1 and team 2 on the same line. i tried applying conditional sentences , but its still giving me the same run time error