Newly learning java and for input, we did
Scanner scan = new Scanner(System.in);
String name;
System.out.println("What is your name?");
name = scan.nextLine();
System.out.println(name);
However, I found that
Scanner scan = new Scanner(System.in);
String name = scan.nextLine();
System.out.println(name);
works the same. Is this being taught to me in the bigger form because it's more generally used/is clearer or am I just being taught the bigger form since I'm a beginner to avoid too much confusion? (Basically, are there any reasons why people would use the expanded version rather than the condensed version?)