import java.util.Hashtable;
import java.util.Random;
public class Lottal {
	public static void main(String[] args) {
		Hashtable hashtable = new Hashtable();
		Random rm = new Random();
		int RmNum = 10;
		for (int i = 0; hashtable.size() < RmNum; i++) {
			int nValue = rm.nextInt(100);
			if (!hashtable.containsValue(nValue) && nValue != 0)// 去重
			{
				hashtable.put(nValue, nValue);
			}
		}
		System.out.println(hashtable.values());
	}
}
----------------------------------------------------
import java.lang.reflect.Array;
import java.util.Random;
public class Lottal {
	private int num;
	private int length;
	private int[] array;
	public Lottal(int num, int length) {
		this.num = num;
		this.length = length;
	}
	public void getRandom() {
		Random rnd = new Random();
		array = new int[length];
		for (int i = 0; i < length; i++) {
			int rndNum = rnd.nextInt(num + 1);
			array[i] = rndNum;
			System.out.println(array[i]);
		}
	}
	public String getLottalResult() {
		for (int i = 0; i < num - 1; i++) {
			System.out.println();
		}
		return array.toString();
	}
	public static void main(String[] args) {
		Lottal lottal = new Lottal(3, 3);
		lottal.getRandom();
	}
}
---------------------------------
Hashtable hashtable = new Hashtable();
  Random rm = new Random();
  int RmNum = 100;
  for (int i = 0; hashtable.Count < RmNum; i++)
  {
    int nValue = rm.Next(100);
    if (!hashtable.ContainsValue(nValue) && nValue != 0)//去重
    {
    hashtable.Add(nValue, nValue);
    Console.WriteLine(nValue.ToString());
    }
  }
----------------------------------
import java.util.Random;
public class testRandom {
	public static void main(String[] args) {
		Random test = new Random();
		int[] a = new int[10];
		int index;
		for (index = 0; index < a.length; index++) {
			a[index] = index + 1;
		}
		index--;
		int tempIndex, tempContent;
		for (; index >= 0; index--) {
			tempIndex = test.nextInt(a.length);
			tempContent = a[index];
			a[index] = a[tempIndex];
			a[tempIndex] = tempContent;
		}
		for (int i = 0; i < a.length; i++) {
			System.out.print(a[i] + "  ");
		}
	}
}
----------------------------------
args[]
1.Scanner s = new Scanner(System.in);
  int i = s.nextInt();
2.
BufferedRader b = new BufferedReader(new InputStreamReader(System.in));
int i = Integer.parseInt(b.readLine());
一般我用这两个。
--------------------
s.nextInt()表示只接受int的数据。
还有nextDouble()接收double的数据
因为你输入的内容可能有很多种数据类型,s.nextInt()就自动把你输入的数据转化为int型
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintStream;
import java.io.PrintWriter;
public class Tongxuelu {
    public static void main(String[] arg) throws Exception {
        String name2;
        String phonenumber;
        for (int a = 0; a < 5; a++) {
            System.out.println("请输入你的名字");
            BufferedReader name1 = new BufferedReader(
                    new InputStreamReader(System.in));
            name2 = name1.readLine();
            System.out.println("请输入你的电话号码");
            phonenumber = name1.readLine();
            System.out.print("姓名");
            System.out.println(name2);
            System.out.print("电话号码");
            System.out.println(phonenumber);
            try {
                File tongxue = new File("tongxuelu.txt"); //文件的名
                PrintWriter writer = new PrintWriter(new OutputStreamWriter(
                        new FileOutputStream(tongxue, true))); 
            writer.println("姓名:" + name2 + "\t" + "电话号码:" + phonenumber); //写入文件
                writer.flush(); //刷新
                writer.close(); //关闭流
            } catch (Exception e) {
                e.printStackTrace();
          }
        }
    }
}
实现输入名字和号码,显示你所输入的信息。