java - How to compare nextLine() to a String -



java - How to compare nextLine() to a String -

i have assignment in apcs class asks create combination lock , think have basic construction down. however, maintain running problem won't allow me compare raw nextline() string.

i wondering if nextline()s default ints? or tell me what's wrong code?

if((in.nextline()).compareto(combo)) { system.out.println("the lock unlocked."); system.out.println("please come in combo unlock: "); if((in.nextline()).compareto(combo)) { system.out.println("the lock locked."); } else { system.exit(0); } }

p.s. ide returns error: "error: incompatible types: int cannot converted boolean" , referring if qualifications.

nextline() homecoming string, isn't problem.

compareto(str) returns negative number if str lexicographically less value beingness compared to, 0 if strings lexicographically equal, or positive number if str lexicographically more value beingness compared to.

you want utilize equals(str), returns boolean value.

java

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -