I am very new to Java and have been trying to figure out this question. Why does taking an input after print and taking it after println differ the order of execution.
Scanner input = new Scanner(System.in);
System.out.println("Enter real part of the number:");
r=input.nextInt();
System.out.println("Enter imaginary part of the number:");
i=input.nextInt();
Output
Enter real part of the number:
1
Enter imaginary part of the number:
2
Scanner input = new Scanner(System.in);
System.out.print("Enter real part of the number:");
r=input.nextInt();
System.out.print("Enter imaginary part of the number:");
i=input.nextInt();
Output
1
2
Enter real part of the number:Enter imaginary part of the number: