This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

K & B example Problem.

 
Soumya Ranjan Mohanty
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



Code is from K&B page no 501. i am not getting the output.

i execute: java ScanIn "\d\d";
input : 12aa675fks
got output as : found null
 
sumit kothalikar
Ranch Hand
Posts: 91
Notepad
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the code compiles fine and i got this as

java ScanIn "\d\d"
input: 12aa675fks

Output :

found 12
found 67
found null

please recompile and check again for your output
 
Sahil Kapoor
Ranch Hand
Posts: 316
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Soumya Ranjan Mohanty wrote:




I thinkk you are asking that , you are not getting last output ie found = null

The reason is do-while loop , if you use while loop then you would not get the last output.

In do-while loop first token is retrieved and then printed and at last checked against null.


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic