• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

this global variable must go!  RSS feed

 
Ranch Hand
Posts: 161
  • 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.
 
Ranch Hand
Posts: 2676
  • 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.
 
Ranch Hand
Posts: 7729
  • 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
 
Sheriff
Posts: 9087
12
  • 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
  • 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
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you for your answers!
I'll try "my very best"
Juliane
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!