Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

this global variable must go!

 
juliane gross
Ranch Hand
Posts: 161
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this global variable must go! Pass this data via parameter.

this text was my last nitpick.
For hours I studied my code, my books,
got nice ideas for solving other nitpicks, but not for this one. Then I studied other SortNames help cries on this site, but nobody had problems similar to mine! Or so it seems.
The assignment says: "Load an ArrayList with Strings from a text file of names".
Well, I did this, right in the second line of code after my "public class SortNames.."
saying:

Then I let the add() method of TextFileIn fill up this list.
Then the main method (and other) take care of sorting and printing the stuff.
If I have no ArrayList first thing, how can I fill it then??
WHAT parameter could pass it, and how??
Usually I always have SOME idea, but this time I feel like giving up on this.
A leeettle tiny hint would be highly apreciated.
Thank you, experienced folks.
 
Matthew Phillips
Ranch Hand
Posts: 2676
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the concept is to write a method that you pass an ArrayList to, populate the ArrayList in that method and return the ArrayList.
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Juliane, you said:
Then I let the add() method of TextFileIn fill up this list.

What add() method?
I think the static attribute could be your problem
-Barry
 
Marilyn de Queiroz
Sheriff
Posts: 9059
12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What if you make it a local variable rather than a class or member variable.
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I should have said we should not use a static in this case
 
juliane gross
Ranch Hand
Posts: 161
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you for your answers!
I'll try "my very best"
Juliane
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic