public static Integer[] generateBySet(int begin, int end, int size) {
		if (begin > end) {
			int temp = begin;
			begin = end;
			end = temp;
		}
		// 加入逻辑判断，确保begin<end并且size不能大于该表示范围
		if ((end - begin) < size) {
			throw new UtilException("Size is larger than range between begin and end!");
		}

		Random ran = new Random();
		Set<Integer> set = new HashSet<Integer>();
		while (set.size() < size) {
			set.add(begin + ran.nextInt(end - begin));
		}

		Integer[] ranArr = set.toArray(new Integer[size]);
		return ranArr;
	}
public static Integer [ ] generateBySet ( int begin , int end , int size ) { if ( begin > end ) { int temp = begin ; begin = end ; end = temp ; } if ( ( end - begin ) < size ) { throw new UtilException ( "Size is larger than range between begin and end!" ) ; } Random ran = new Random ( ) ; Set < Integer > set = new HashSet < Integer > ( ) ; while ( set . size ( ) < size ) { set . add ( begin + ran . nextInt ( end - begin ) ) ; } Integer [ ] ranArr = set . toArray ( new Integer [ size ] ) ; return ranArr ; }
生成不重复随机数 根据给定的最小数字和最大数字，以及随机数的个数，产生指定的不重复的数组

@param begin 最小数字（包含该数）
@param end 最大数字（不包含该数）
@param size 指定产生随机数的个数
@return 随机int数组