Finding tokens within a string using a searching loop JAVA : <p>So basically I'm trying to write a method that takes 2 strings as parameters and returns a boolean. It returns true if t occurs as a token within s, and returns false if otherwise. </p>

<p>I'm pretty new to coding so I don't really know what i'm doing wrong, any help is appreciated! </p>

<p>Here's my code:</p>

<pre><code>public static boolean containsToken(String s, String t) {

 Scanner scr = new Scanner(s);
</code></pre>

<p>This scanner breaks up String s into tokens</p>

<pre><code>for(int i = 0; i &lt; s.length(); i++) {
</code></pre>

<p>I tried to make this for loop search through the length of s for tokens that match up with String t </p>

<pre><code>if(t.contains(scr.next()))

return true;
}
return false; 


} 
</code></pre>
