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

WordCounter array problems  RSS feed

 
Gabriel White
Ranch Hand
Posts: 233
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a quick question. My main method listed below will not pass my array values into my constructor WordCounter. Is is due to the instantiation of t1 in my for loop? I know the array is being filled correctly with the strings because I can test it with a SOP, and it outputs correctly. Im just wondering why this doesn't work.
The constructor in my WordCounter class accepts a String object.
It works when I instantiate all 4 objects individually, but I was hoping to get away with this code.
Thanks in advance.

And here is the constructor for WordCounter:


[ January 20, 2004: Message edited by: Steve Wysocki ]
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My main method listed below will not pass my array values into my constructor WordCounter.
How do you know this? Try putting a print statement inside the constructor to see what if any value it's seeing.
Also, this line does nothing:

That is, it does execute the toString() method, which creates a string. But it doesn't do anything with that string afterwards. Try:

[ January 20, 2004: Message edited by: Jim Yingst ]
 
Gabriel White
Ranch Hand
Posts: 233
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jim, total brain fart here on my part.
I can't believe I just posted that.
Thanks for your help.
Steve
[ January 20, 2004: Message edited by: Steve Wysocki ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!