• Post Reply Bookmark Topic Watch Topic
  • New Topic

Whats wrong with this java code?  RSS feed

 
Sujath Mohammed
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to store a whole line from a txt file into an array i managed to do that but when it comes to searching from the array i can't seem to do that.Here's the code:


It doesn't display the result
 
Ashish Dutt
Ranch Hand
Posts: 172
Java MySQL Database Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sujath Mohammed wrote:I want to store a whole line from a txt file into an array i managed to do that but when it comes to searching from the array i can't seem to do that.Here's the code:
It doesn't display the result

What happens, when you run this code?
Please tell us what its supposed to display according to your programming logic and what it does not display, what errors or exceptions you get etc.... then we can have a more meaningful discussion.
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sujath Mohammed wrote:I want to store a whole line from a txt file into an array i managed to do that but when it comes to searching from the array i can't seem to do that.

Because you're not doing what you say you want to, which is to read lines. What do the docs for Scanner.read() say? And, given your stated objective, what Scanner method do you think might be a better choice?

Winston
 
Campbell Ritchie
Marshal
Posts: 56600
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I presume by Scanner.read(), you mean Scanner#next().
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:I presume by Scanner.read(), you mean Scanner#next().

Er...yuh. Doh-h-h!

Winston
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!