试题乱序


public static void main(String[] args) {
		String s ="['A.besides','B. despite','C. regardless ','D.except for']";
	JSONArray jsonArray = JSONArray.fromObject( s);
	PaperTeacherManager paperTeacherManager = new PaperTeacherManager();
	Object[] o = jsonArray.toArray();
	for(Object obj:o){
		
		System.out.println(obj.toString());
	}
	
	
	
	Object[] oa = paperTeacherManager.getSequence(o);
	for(Object obj:oa){
		
		System.out.println(obj.toString());
	}
	}
	  /**
     * 对给定数目的自0开始步长为1的数字序列进行乱序
     * @param  
     * @return 乱序后的数组
     */
    public Object[] getSequence(Object[] sequence) {
        
        Random random = new Random();
        for(int i = 0; i < sequence.length; i++){
            int p = random.nextInt(sequence.length);
            Object tmp = sequence[i];
            sequence[i] = sequence[p];
            sequence[p] = tmp;
        }
        random = null;
        return sequence;
    }







你可能感兴趣的:(试题)