Generate Random IP Address
<p>I want to generate some random IP Address. But evertime this generateIPAddress function returns 0.0.0.0 string as ipAddress. But it should be returning some random ipAddress other than 0.0.0.0 everytime. Any suggestions why is it happening?</p>

<pre><code>private void callingGeoService() {
        int p1 = 255;
        int p2 = 0;
        int p3 = 0;
        int inc = 5;

        String ipAddress = generateIPAddress(p1, p2, p3);

        p3 += inc;
        if (p3 &gt; 255) {
            p3 = 0;
            p2 += inc;
            if (p2 &gt; 255) {
                p2 = 0;
                p1--;
                if (p1 &lt;= 0) {
                    p1 = 0;
                }
            }
        }
    }
</code></pre>

<p>//This is the generateIPAddress method</p>

<pre><code>private String generateIPAddress(int p1, int p2, int p3) {

    StringBuilder sb = null;

    int b1 = (p1 &gt;&gt; 24) &amp; 0xff;
    int b2 = (p2 &gt;&gt; 16) &amp; 0xff;
    int b3 = (p3 &gt;&gt;  8) &amp; 0xff;
    int b4 = 0;

    String ip1 = Integer.toString(b1);
    String ip2 = Integer.toString(b2);
    String ip3 = Integer.toString(b3);
    String ip4 = Integer.toString(b4);

    //Now the IP is b1.b2.b3.b4
    sb = new StringBuilder();
    sb.append(ip1).append(".").append(ip2).append(".").append(ip3).append(".").append(ip4);
    // System.out.println(sb);

    return sb.toString();

}
</code></pre>

<p>I want some random ipAddress basically so I have hardcoded starting ipAddress bits in the form of p1,p2,p3 and last bit should be 0.</p>
