Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • 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 ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Word Counter

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.
Hey, sticks and stones baby. And maybe a wee mention of my stuff:
Thread Boost feature
    Bookmark Topic Watch Topic
  • New Topic