java中Random的用法
import java.util.Random;
public class MathOperators {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
//随机数的产生
int[] arr = new int[10];
Random r = new Random();
for (int m = 0; m < arr.length; m++)
{
arr[m] = r.nextInt(100);
}
for (int n = 0; n < arr.length; n++)
{
System.out.println(arr[n]);
}
}
}
相关文档:
/************Student.java begin***************/
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public class Student {
private String name;
private String password;
public String getName() {
return name;
}
public ......
JDK1.4中
Map map = new HashMap();
Iterator it = map.entrySet().iterator();
while (it.hasNext()) {
Map.Entry entry = (Map.Entry) it.next();
Object key = entry.getKey();
Object value = entry.getValue();
}
JDK1.5中,应用新特性For-Each循环
Map m = new HashMap();
......
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class BubbleSort {
private static int a[] = new int[12];
private static BufferedReader in = new BufferedReader(
new InputStreamReader(System.in));
public static void bubbleSort(int a[], i ......