Created
August 26, 2011 05:34
-
-
Save kurochan/1172775 to your computer and use it in GitHub Desktop.
0~9までの乱数を1000行出力するだけのサーブレット
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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