• Post Reply Bookmark Topic Watch Topic
  • New Topic

String array problem  RSS feed

 
kunagu varun
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello friends the following is a head banging problem i am currently suffering from.. please have a look at it..


Inside the while loop everything works fine.. The text file is opened and saved in the string array and printed..But out side the for,i am trying to print the saved array string, But i am getting only null as the output...

Please solve this issue...
 
Martin Vanyavchich
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the second loop you're incrementing variable i, in stead of variable k.

 
Hunter McMillen
Ranch Hand
Posts: 492
Firefox Browser Linux VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
print this out inside your while loop and see what it does:



Hunter
 
Matthew Brown
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And think about what the value of fileLine[k] is going to be when you exit the while loop.
 
Abimaran Kugathasan
Ranch Hand
Posts: 2066
Clojure IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your logic is the problem, in the while loop, you assigned the whole Strings from your file including null(End of File) to a single array element fileLine[k]. Correct it. (Finally you assigned null to your fileLine[k] single element, then you check whether that element is null or not - the problem is here. Have a deep look.)
 
kunagu varun
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much for the replies... I will try the suggestions and post the results back...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!