Substring of string is not working the way i want : <p>I have this code here:    </p>

<pre><code>String line1 = "part1, part2, part3, part4";
</code></pre>

<p>and i  want to extract part 2.
so i tried this:</p>

<pre><code>String extractedPart = line1.substring(line1.indexOf(","), line1.indexOf(",", line1.indexOf"," +1)));

System.out.println(extractedPart);
</code></pre>

<p>But it's not printing out anything.
Can someone help me with that?</p>
