• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Scanner Doubt

 
Abhi vijay
Ranch Hand
Posts: 509
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Source: Examlab



The answer is 100,55. I dont understand why 127 3L are not included?
 
Punit Singh
Ranch Hand
Posts: 952
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Try this.

And scanner will stop at 3L, will not scan after that.



As we have not used s.hasNext();



 
Ankit Garg
Sheriff
Posts: 9528
33
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Punit the second code that you gave will result in an infinite loop. Change the code like this

 
Punit Singh
Ranch Hand
Posts: 952
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ankit, actually I was in bit hurry, thats why I wrote that in speed.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic