need help for string

i face a problem where i wan compare the contain of the string, let say

string a = "java is cool";

string b = "well java is cool";

the tokens for a =3 n b=4,

i wan compare the whole line using tokenizer, where the b have the similar string on a.

the result will be,

token 2 3 4 from b is simalar with a

i also very blur wat i'm saying...hopefully u can understand...thx

[420 byte] By [shadowssssa] at [2007-10-2 8:24:46]
# 1
Why not just tokenize (or better, split) and then compare from the right? How hard is that?Harder than typing intelligible English sentences, I will grant you, but...Drake
Drake_Duna at 2007-7-16 22:24:33 > top of Java-index,Other Topics,Algorithms...
# 2
Are you trying to find a substring?
algra at 2007-7-16 22:24:33 > top of Java-index,Other Topics,Algorithms...
# 3

i'm not want to find the substrings..

i just wan to prove string b having the same content from string a...

where string a is the original sentence, and string b is copy from a..

the result will be...display out which letter is copy from string a...

well i think using other method such as

if i use 2 LOOP, compare token by token ....

Like This :

A1 compare to B1, A1 == B2, A1 == B3?

A2 == B1, A2 == B2, A3 == B3 ......

then izit whether we need using a matrix 2 do it?

shadowssssa at 2007-7-16 22:24:33 > top of Java-index,Other Topics,Algorithms...
# 4
If you want to retain the order of string A, I would use split to return the substrings. Keep incrementing through B until A[0] == B. Then increment both A and B comparing the words at each step.
Hoju2468a at 2007-7-16 22:24:33 > top of Java-index,Other Topics,Algorithms...
# 5
That should be: A(0) == B(i)
Hoju2468a at 2007-7-16 22:24:33 > top of Java-index,Other Topics,Algorithms...
# 6

> i face a problem where i wan compare the contain of

> the string, let say

>

> string a = "java is cool";

> string b = "well java is cool";

>

> the tokens for a =3 n b=4,

>

> i wan compare the whole line using tokenizer, where

> the b have the similar string on a.

>

> the result will be,

>

> token 2 3 4 from b is simalar with a

>

Presumably order is not an issue.

You want to do words?

- Use the java docs and look at String.split()

- Then compare the two arrays.

jschella at 2007-7-16 22:24:33 > top of Java-index,Other Topics,Algorithms...
# 7
any place can see the String.split() fucntion arr?my java book dun have...thx guys
shadowssssa at 2007-7-16 22:24:33 > top of Java-index,Other Topics,Algorithms...
# 8

> any place can see the String.split() fucntion arr?

> my java book dun have...

>

> thx guys

If you mean to type this: "Is there any place where I can see an example of the String.split() method? My Java book doesn't have one." then here's an example:

/*

Check the API doc:

http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html

*/

public class Test {

public static void main(String[] args) {

String str = "java is cool";

String[] array = str.split(" ");

for(int i = 0; i < array.length; i++) {

System.out.println("array["+i+"] --> "+array[i]);

}

}

}

prometheuzza at 2007-7-16 22:24:33 > top of Java-index,Other Topics,Algorithms...