Unable to Understand the pre-Written code

Mam Im unable to understand the pre-written code also can u please help me by helping me to use inbuild linked list class .Can u please explain the pre-Written code?

Exception in thread β€œmain” java.util.InputMismatchException at java.util.Scanner.throwFor(Scanner.java:864) at java.util.Scanner.next(Scanner.java:1485) at java.util.Scanner.nextInt(Scanner.java:2117) at java.util.Scanner.nextInt(Scanner.java:2076) at Main.buildList(Main.java:77) at Main.main(Main.java:106)

Mam im unable to understand the input format.

try to test it with input as
1 2 3 -1
4 2 3 -1

not the one given,what part of the code do u have problem in?