#Java - Code Snippets for '#Java.util.Random' - 3 code snippet(s) found |
|
Sample 1. Generate Random Number till 100 | |
|
Random rand = new Random();
int randomNumber = rand.nextInt(100);
|
|
Like Feedback Random Number Generation Random |
|
|
Sample 2. Code Sample / Example / Snippet of java.util.Random | |
|
public Enumerable<Object[]> scan(DataContext root) {
final Random random = seed >= 0 ? new Random(seed) : new Random();
final Maze maze = new Maze(width, height);
final PrintWriter pw = new PrintWriter(System.out);
maze.layout(random, pw);
if (Maze.DEBUG) {
maze.print(pw, true);
}
return new AbstractEnumerable<Object[]>() {
public Enumerator<Object[]> enumerator() {
final Set<Integer> solutionSet;
if (solution) {
solutionSet = maze.solve(0, 0);
} else {
solutionSet = null;
}
return Linq4j.transform(maze.enumerator(solutionSet),
new Function1<String, Object[]>() {
public Object[] apply(String s) {
return new Object[] {s};
}
});
}
};
}
|
|
Like Feedback java.util.Random |
|
|
Sample 3. Code Sample / Example / Snippet of java.util.Random | |
|
private File createRandomFileWithContent() throws IOException {
OutputStream fileOut = null;
File file = null;
try {
file = FileUtils.createTempFile(null);
fileOut = new FileOutputStream(file);
byte[] byteArray = new byte[12345];
Random randomContentCreator = new Random();
randomContentCreator.nextBytes(byteArray);
fileOut.write(byteArray);
return file;
}
finally {
try {
if (fileOut != null) {
fileOut.close();
}
}
catch (IOException e) {
throw e;
}
}
}
|
|
Like Feedback java.util.Random |
|
|