Instead of printing out each statement and waiting for input it prints out both statements and waits for one input.
for(int i=0; i < size; i++)
{
System.out.println("course: ");
courses[i] = sc.nextLine();
System.out.println("teacher: ");
teachers[i] = sc.nextLine();
}
Output:
Enter number of classes: 2 course:
teacher: