•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Java section within the Software Development category of DaniWeb, a massive community of 391,579 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,716 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Java advertiser: Lunarpages Java Web Hosting
Views: 1655 | Replies: 3
![]() |
•
•
Join Date: Sep 2004
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
here is the code...
String string = "superboymother"; // string variable contains the string that u want to search
int aCount = 0;
int eCount = 0;
int iCount = 0;
int oCount = 0;
int uCount = 0;
char[] stringBrocken = string.toCharArray();
for(int i=0; i<stringBrocken.length; i++) {
if(brockenString[i] == 'a') {
aCount += 1;
}
if(brockenString[i] == 'e') {
eCount += 1;
}
if(brockenString[i] == 'i') {
iCount += 1;
}
if(brockenString[i] == 'o') {
oCount += 1;
}
if(brockenString[i] == 'u') {
uCount += 1;
}
}
// Now you got the counts for each letters
String string = "superboymother"; // string variable contains the string that u want to search
int aCount = 0;
int eCount = 0;
int iCount = 0;
int oCount = 0;
int uCount = 0;
char[] stringBrocken = string.toCharArray();
for(int i=0; i<stringBrocken.length; i++) {
if(brockenString[i] == 'a') {
aCount += 1;
}
if(brockenString[i] == 'e') {
eCount += 1;
}
if(brockenString[i] == 'i') {
iCount += 1;
}
if(brockenString[i] == 'o') {
oCount += 1;
}
if(brockenString[i] == 'u') {
uCount += 1;
}
}
// Now you got the counts for each letters
ranyodh you are too smart.... I was using String.indexOf() ....But your way looks better than mine if it is the matter of only a few letters or numbers.
•
•
Join Date: Aug 2004
Posts: 4
Reputation:
Rep Power: 0
Solved Threads: 0
String string = "superboymother"; // string variable contains the string that u want to search
int aCount = 0;
int eCount = 0;
int iCount = 0;
int oCount = 0;
int uCount = 0;
char[] stringBrocken = string.toCharArray();//i don't readily understand can example?
for(int i=0; i<stringBrocken.length; i++) {//i don't readily understand can example?
if(brockenString[i] == 'a') {//i don't readily understand can example?
aCount += 1;
}
if(brockenString[i] == 'e') {
eCount += 1;
}
if(brockenString[i] == 'i') {
iCount += 1;
}
if(brockenString[i] == 'o') {
oCount += 1;
}
if(brockenString[i] == 'u') {
uCount += 1;
}
}
int aCount = 0;
int eCount = 0;
int iCount = 0;
int oCount = 0;
int uCount = 0;
char[] stringBrocken = string.toCharArray();//i don't readily understand can example?
for(int i=0; i<stringBrocken.length; i++) {//i don't readily understand can example?
if(brockenString[i] == 'a') {//i don't readily understand can example?
aCount += 1;
}
if(brockenString[i] == 'e') {
eCount += 1;
}
if(brockenString[i] == 'i') {
iCount += 1;
}
if(brockenString[i] == 'o') {
oCount += 1;
}
if(brockenString[i] == 'u') {
uCount += 1;
}
}
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb Java Marketplace
- Having difficulty with a WordCount Program (Java)
- Ideas needed for problem with trailing whitespaces (C++)
- Getting words (PHP)
Other Threads in the Java Forum
- Previous Thread: Mortgage Calculation
- Next Thread: Pass XML file contents to a hash table.



Linear Mode