Skip to content

Instantly share code, notes, and snippets.

@kurochan
Created August 26, 2011 05:34
Show Gist options
  • Save kurochan/1172775 to your computer and use it in GitHub Desktop.
Save kurochan/1172775 to your computer and use it in GitHub Desktop.
0~9までの乱数を1000行出力するだけのサーブレット
import java.io.IOException;
import java.util.Random;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@SuppressWarnings("serial")
public class ProbabilityTestServlet extends HttpServlet {
private final int SAMPLES = 1000;
private final int MAX_NUMBER = 10;
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws IOException {
resp.setContentType("text/plain");
Random rnd = new Random();
for (int i = 0; i < SAMPLES; i++) {
resp.getWriter().println(rnd.nextInt(MAX_NUMBER));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment