java.util.scanner - Can I create a String variable that will always be the newest nextLine() Scan? -


because creating new string variable next line stored next line of whatever printout is, there way me create new string variable newest nextline()? want don't have keep making new strings collect each new line of input.

thanks help!

yes, example below:

scanner scan = new scanner(system.in);   out.println("enter something: "); //user enters "some" string scaninfo = scan.nextline();  out.println(scaninfo); //outputs "some"   out.println("enter something: "); //user enters "thing" scaninfo = scan.nextline();  out.println(scaninfo); //outputs "thing" 

just make sure know being rewritten every time not able access again. careful .nextline , .nextint (as wont able save .nextint string variable)

another idea (not sure exact implementation looking for) use stack, because can keep track of of scanned in information , can pop off recent scanned value


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -