fork download
  1. import java.util.Random;
  2.  
  3. class Ideone {
  4.  
  5. public static void main(String[] args) {
  6. System.out.println("2d6 = " + d(2, 6));
  7. }
  8.  
  9. static int d(int i, int s) {
  10. return random.ints(i, 1, s + 1).sum();
  11. }
  12.  
  13. static Random random = new Random();
  14. }
Success #stdin #stdout 0.22s 320704KB
stdin
Standard input is empty
stdout
2d6 = 6