title: I cant understand this lastindexof method in Java 11
body: <pre><code>    int a=&quot;abcd&quot;.indexOf(&quot;d&quot;,0);
      int b=&quot;abcd&quot;.indexOf(&quot;d&quot;,1);
      int c=&quot;abcd&quot;.indexOf(&quot;d&quot;,2);
      int d=&quot;abcd&quot;.indexOf(&quot;d&quot;,3);
      int e=&quot;abcd&quot;.indexOf(&quot;d&quot;,4);
      int f=&quot;abcd&quot;.indexOf(&quot;d&quot;,5);
  
  
  
  
      int b1=&quot;abcd&quot;.indexOf(&quot;d&quot;,-1);
      int c1=&quot;abcd&quot;.indexOf(&quot;d&quot;,-2);
      int d1=&quot;abcd&quot;.indexOf(&quot;d&quot;,-3);
      int e1=&quot;abcd&quot;.indexOf(&quot;d&quot;,-4);
      int f1=&quot;abcd&quot;.indexOf(&quot;d&quot;,-5);
  
  
      System.out.println(&quot;Last index of from index 0 &quot;+a);
      System.out.println(&quot;Last index of from index 1 &quot;+b);
      System.out.println(&quot;Last index of from index 2 &quot;+c);
      System.out.println(&quot;Last index of from index 3 &quot;+d);
      System.out.println(&quot;Last index of from index 4 &quot;+a);
      System.out.println(&quot;Last index of from index 5 &quot;+f);
  
  
      System.out.println(&quot;Last index of from index -1 &quot;+b1);
      System.out.println(&quot;Last index of from index -2 &quot;+c1);
      System.out.println(&quot;Last index of from index -3 &quot;+d1);
      System.out.println(&quot;Last index of from index -4 &quot;+e1);
      System.out.println(&quot;Last index of from index -5 &quot;+f1);
  </code></pre>
  <p>Results</p>
  <pre><code>Last index of from index 0 3
  Last index of from index 1 3
  Last index of from index 2 3
  Last index of from index 3 3
  Last index of from index 4 3
  Last index of from index 5 -1
  Last index of from index -1 3
  Last index of from index -2 3
  Last index of from index -3 3
  Last index of from index -4 3
  Last index of from index -5 3
  </code></pre>
  <p>Can someone explain how positive and negative index work?</p>