public static void main(String[] args){
Scanner sc = new Scanner(System.in);
System.out.println("Enter two numbers: ");
int a = sc.nextInt();
int b = sc.nextInt();
System.out.println("Enter two decimal numbers: ");
float x = sc.nextFloat();
float y = sc.nextFloat();
System.out.println("Enter two words: ");
String i = sc.nextLine();
String j = sc.nextLine();
//System.out.println(i);
//System.out.println(j);
System.out.println(max(a,b));
System.out.println(max(x,y));
System.out.println(max(i,j));
}
I'm still learning java, I tried removing "Line" and writing my two words inputs in the same line separated by a space and it worked but can someone explain why "nextLine" skips the first String input even though it executes both ints and both floats ?