As a starting point you could use this code, it implements the sum notation as described here Leibniz formula for π

```
public class PI {
public static void main( String[] args) {
double PI4 = 1.0;
for ( int i = 1 ; i <= 50 ; i++ ) {
double nom = Math.pow( -1, i );
double denom = 2 * i + 1;
PI4 += nom / denom;
}
System.out.println( "result=" + PI4 * 4 );
}
}
```

After 50 iterations the result is 3.1611986129870506