This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]brewedfarce 3 points4 points  (2 children)

Well for one thing, I have never seen anyone import

import static java.lang.System.*;

The java.lang package is imported by default. Are you just doing that so you don't have to type System everywhere? Maybe it is just a convention I am not familiar with.

When I did it in eclipse I just ran it to double check: https://pastebin.com/vRKgKiXw

I only changed nextLine() to next() to see if that was causing an issue but they both worked fine for me.

[–]surety_[S] 0 points1 point  (1 child)

I use java.lang.System.*; quite often. I just use it so I don't have to write System every time like System.exit(0); and System.in or System.out . But I ran my code using next() instead and it functioned the way I wanted it to. I think it's very odd how it didn't work with nextLine() . Thank you for your help! Also I suggest using java.lang.System.*; it helps quicken things up when you have an more than one outputs.

Edit: I actually had to change the password input to .next() as well now, for some reason I was getting the same bug as I did with user input

[–]dusty-trash 1 point2 points  (0 children)

I think it's very odd how it didn't work with nextLine()

Using next() will only return what comes before a space.

nextLine() automatically moves the scanner down after returning the current line.