aspose file tools*
The moose likes Cattle Drive and the fly likes this global variable must go! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » This Site » Cattle Drive
Bookmark "this global variable must go!" Watch "this global variable must go!" New topic
Author

this global variable must go!

juliane gross
Ranch Hand

Joined: May 30, 2002
Posts: 161
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

Joined: Mar 09, 2001
Posts: 2676
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.


Matthew Phillips
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
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


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9046
    
  10
What if you make it a local variable rather than a class or member variable.


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
I should have said we should not use a static in this case
juliane gross
Ranch Hand

Joined: May 30, 2002
Posts: 161
thank you for your answers!
I'll try "my very best"
Juliane
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: this global variable must go!