• Post Reply Bookmark Topic Watch Topic
  • New Topic

Word Counter  RSS feed

 
Gabriel White
Ranch Hand
Posts: 233
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Yall, just wondering if anybody could shed some light on my code here. I am supposed to create a program that counts the words that I enter in my main method and then print them in original form and lowercase form. I have instantiated 4 objects (strings) in my main method. Thoes strings get passed into my WordCounter class. My WordCounter class is an extension of the Counter class. My Counter class was given to me and is not to be altered. I am having a problem with nulls. When I run the main method all I get are nulls. I understand why I am getting them, but I'm not really sure how to get around them. I have tested the string array in the constructor by placing a SOP in there and the output matches the strings in my main method. So at least I know the array is filling up. The nulls are coming from the getLowerCase and getOriginal methods. I thought I had the problem solved when I added the "this" command to them, but no change.
Anyway, here is the code:
Thanks in advance

Counter class

Main method

[ January 16, 2004: Message edited by: Steve Wysocki ]
 
Gabriel White
Ranch Hand
Posts: 233
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Never mind, figured it out...Bonehead mistake.
this.myStrings[i] instead of this.aWord
aWord is null when that method is called.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!