• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

this global variable must go!

 
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you for your answers!
I'll try "my very best"
Juliane
 
Goodbye moon men. Hello tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic