Results 1 to 18 of 18
- 07-23-2011, 01:10 AM #1
Member
- Join Date
- May 2011
- Posts
- 39
- Rep Power
- 0
- 07-23-2011, 01:34 AM #2
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
I don't believe there are any methods for counting words. Doing this yourself with charAt or substring should be relatively easy.
- 07-23-2011, 01:46 AM #3
Member
- Join Date
- May 2011
- Posts
- 39
- Rep Power
- 0
What about whole objects?
-
- 07-23-2011, 01:49 AM #5
Moderator
- Join Date
- Jul 2010
- Location
- California
- Posts
- 1,605
- Rep Power
- 5
Define record...an object? A collection of objects? A database entry? A file? Words in a file? Your question is not detailed enough for a detailed answer. What exactly do you want to count?
- 07-23-2011, 01:49 AM #6
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
I'm not exactly sure what you mean, a string is an Object.
- 07-23-2011, 01:51 AM #7
Member
- Join Date
- May 2011
- Posts
- 39
- Rep Power
- 0
Like one whole record is equal to one object... would you count that with a while loop? I'm confused..
-
- 07-23-2011, 01:53 AM #9
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
Sure. You should just write a method that looks like this
And then think how you would repeatedly test the next character.Java Code:public int countWords(String s)
- 07-23-2011, 01:53 AM #10
Member
- Join Date
- May 2011
- Posts
- 39
- Rep Power
- 0
Yes I mean like a database...
Example:
StudentName StudentID StudentGpa <---- That would be equal to one record.
- 07-23-2011, 01:54 AM #11
Member
- Join Date
- May 2011
- Posts
- 39
- Rep Power
- 0
So how would you count one record after the other? Would a while loop be sufficient enough to pull this off?
- 07-23-2011, 02:11 AM #12
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
Try and see what you can come up with.
- 07-23-2011, 02:24 AM #13
Member
- Join Date
- May 2011
- Posts
- 39
- Rep Power
- 0
This is what I have come up with so far...Java Code:public int countRecords() { int recordCounter; while( recordCounter <= classCode.length) { recordCounter++; } int gpaAverage = recordCounter/classCode.length; }
- 07-23-2011, 02:29 AM #14
Member
- Join Date
- May 2011
- Posts
- 39
- Rep Power
- 0
It didn't compile, here are the errors
Java Code:F:\PA2\GpaRecord.java:111: int cannot be dereferenced while( recordCounter <= classCode.length) ^ F:\PA2\GpaRecord.java:115: int cannot be dereferenced int gpaAverage = recordCounter/classCode.length; ^ 2 errors
- 07-23-2011, 04:05 AM #15
Moderator
- Join Date
- Jul 2010
- Location
- California
- Posts
- 1,605
- Rep Power
- 5
Your questions are coming out of left field, with absolutely no context whatsoever. We can't help you if you do not provide this context. If you want help, I recommend you read, study, and following the guidelines in the following link: How To Ask Questions The Smart Way
- 07-23-2011, 10:43 AM #16
Member
- Join Date
- May 2011
- Posts
- 39
- Rep Power
- 0
- 07-25-2011, 10:47 AM #17
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
As has been asked.
What are you counting?
You talk about "records", but that's a meaningless term in Java, outside of certain frameworks.
So what is a record?
Where are these records?
They are presumably not in a array since you say you can't use an array to do this.
- 07-25-2011, 12:42 PM #18
Member
- Join Date
- Mar 2010
- Posts
- 16
- Rep Power
- 0
Similar Threads
-
need to input values from a text file into an array and count values
By pds8475 in forum New To JavaReplies: 14Last Post: 01-22-2011, 02:36 PM -
How do I count empty spaces in a byte array?
By nessa203 in forum New To JavaReplies: 13Last Post: 01-11-2010, 05:46 PM -
insert records
By rudravaram in forum JDBCReplies: 3Last Post: 01-03-2010, 05:54 PM -
i can do count, but having problem with array
By judy318 in forum New To JavaReplies: 4Last Post: 10-29-2009, 09:23 PM -
Array count number Occurances
By gwithey in forum New To JavaReplies: 2Last Post: 04-17-2009, 08:34 PM


1Likes
LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks