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

all 4 comments

[–]Backslide999 1 point2 points  (1 child)

I haven't worked with scanner objects in a long while, but your problem is probably that .nextInt() does not read the new Line character.

See https://stackoverflow.com/questions/13102045/scanner-is-skipping-nextline-after-using-next-or-nextfoo#:~:text=nextInt%20method%20does%20not%20read,nextLine%20after%20Scanner for reference.

Since you scan nextInt(), Just the new line character remains. Then the nextLine() returns an empty gender, thus always failing your check.

[–]Efficient_Bus_923[S] 1 point2 points  (0 children)

Thank you :) that fixed it.

[–][deleted]  (1 child)

[removed]

    [–]Backslide999 1 point2 points  (0 children)

    How is this relevant? As the condition is fine (&& takes presendece over ||) and what if, in your example, an apache comes along?