Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I am afraid, you are not close.</p> <p>Here's what you have to do:</p> <ul> <li>Loop on the characters of the string (the one <em>on</em> which you are supposed to do an <code>indexOf</code>, I will call this the <em>master</em>) (you are going this right) </li> <li>For every character check whether your other string's character and this character are the same. </li> <li>If they are (a potential start of the same sequence) check whether the next characters in the master match with your String to check (You might want to loop through the elements of the string and check one by one). </li> <li>If they don't match, continue with the characters in the master string</li> </ul> <p>Something like: </p> <pre><code>Loop master string for every character (using index i, lets say) check whether this is same as first character of the other string if it is //potential match loop through the characters in the child string (lets say using index j) match them with the consecutive characters in the master string (something like master[j+i] == sub[j]) If everything match, 'i' is what you want otherwise, continue with the master, hoping you find a match </code></pre> <p>Some other points:</p> <ul> <li>In java, method names start with a lower case letter by <em>convention</em> (meaning, the compiler won't complain, but your fellow programmers may). So <code>IndexOf</code> should actually be <code>indexOf</code> </li> <li>Having instance variables (class level variables) start with a <code>_</code> (as in <code>_st</code>) is not a really good practice. If your professor insists, you may not have many options, but keep this in mind)</li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload