input - How to scan words from console and store somewhere (Java)? -


i trying input user, in each line user enters 2 words , later comparing 2 words. program needs accept multiple lines means more 1 comparisons. need know how input user multiple lines. (the input stored in txt file , copy , pasted in console if user inputing) this java thanks

you can use hasnext() function in scanner object

example:

public static void main(string [] args) {      scanner scan = new scanner(system.in);      system.out.println("write ");     while(scan.hasnext()) {          /* while there more input read */     } }  

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -