|
-
August 10th, 2010, 03:46 AM
#7
Re: Returning Memory Location
Your code seems confused - in the VowelCons class you have numVowels and numCons int class variables that are initialized to zero and never used, and you have getNumVowels and geNumCons methods that don't return the numVowels and numCons variables, but regenerate and return the arrays every time they are called (why?).
Until you sort out what those methods are supposed to do and give them appropriate names, and decide what those class variables are going to be used for, you're going to be confused, and people trying to help will be even more confused.
Also, printing an array won't automatically give you a count of the items in the array (why should it?), it will just give you the default 'toString' value for an object, which is className@hashCode. If you want the number of elements in an array, use array.length. If you want to print a list of the items, iterate over the array printing each item in turn.
And why not just initialize the arrays once, instead of regenerating them every time you call the method - the array contents never change, so it's just wasting processor time and memory.
If you cannot describe what you are doing as a process, you don't know what you're doing...
W. E. Deming
Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|