• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

No Element Found Exception

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I Had below element in my occupy.txt which tells number of people in each room
1 3 4 1 0 3 4 2 1 5
and below code is for checking how Many people are in each room

It Works Perfectly fine For Room number 0 to 9 But When I enter Room number Above This instead of
throwing element not found exception it always says Like Room 12 Has 1 Guests any Advice
Thanks In ADVANCE !!!
 
Ranch Hand
Posts: 954
4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
dint understand your question, can you please explain again?
 
Marshal
Posts: 76802
366
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch

I added code tags to your post. Always use the tags; it would have looked a lot better if you had indented the code correctly.
Never never close a Scanner pointing to System.in.
You have not explained how your file works. What do the numbers mean? Maybe you should have a room class which records the room number and how many people have booked.

Look very closely at your for loop heading.
 
Campbell Ritchie
Marshal
Posts: 76802
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Vinay Tripathi wrote:. . . It Works Perfectly fine For Room number 0 to 9 . . .

Not when I tried it, it didn't. It told me 1 guest for everything.
 
I'm THIS CLOSE to ruling the world! Right after reading this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic