Vaibhav
Posts: 4
Nickname: vaibhz
Registered: Aug, 2004
|
|
Re: HELP me in this code
|
Posted: Aug 9, 2004 12:08 AM
|
|
Hi,
This is the dirtiest logic u can find but u can review and modify as per ur requirement ;)
Hope it helps u....
import java.util.*;
class Help { public static void main(String[] args) { String testString= "I am the user I am the user", token = null,temps; int i =0; StringTokenizer st = new StringTokenizer(testString," "); StringTokenizer tempst;
while (st.hasMoreElements()) { token = st.nextToken(); tempst = new StringTokenizer(testString," "); while (tempst.hasMoreTokens()) { temps = tempst.nextToken(); if (temps.equals(token)) { i++; } } System.out.println(token+" "+i); i = 0; } } }
|
|