Even after odd linked lists

Could anyone please tell the Error in my 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)

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 LinkedList.main(LinkedList.java:233)

Your code wont work if both curr and next have even data before and have any number of odd datas after that.
For ex: 2 2 1 2 1. What if both curr.data and next.data have even data?

Please check now. I have made some changes in the code.

Output : error 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 LinkedList.main(LinkedList.java:236)

This is the Error which is displayed.

Check this out. I have made the required changes.

Could some one please answer this Doubt of mine.

Someone could please check my this Doubt.

The problem is still the same as above where I replied before. If two even numbers exist together before any odd number, your code wont work there

My suggestion would be to use 2 linked lists for even and odd and concatenate the even number list after odd one and print it

Okay. Let me try once.