标题:Ramdom类报错,不知道问题出在哪里?
取消只看楼主
大脸猫xiang
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2014-3-30
结帖率:33.33%
已结贴  问题点数:20 回复次数:1 
Ramdom类报错,不知道问题出在哪里?
package my_first_java;
import java.util.Random;
/*****
 * 洗牌算法
 * @author xiang
 *
 */
public class MyFirstJava {

    public static void main(String[] args) {
        String [] cards = {"黑桃A","红桃2","梅花7","梅花7","方块10","黑桃9"};
        Ramdom r = new Random();
        for(int i=cards.length-1; i>=1; i--){
            int j = r.nextInt(i);//j=[0,i)
            String t = cards[i];
            cards[i] = cards[j];
            cards[j] = t;
        }
        
        System.out.println("My first Java program!");// TODO Auto-generated method stub
        System.out.print(cards);
    }

}


编译报错:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
    Ramdom cannot be resolved to a type

    at my_first_java.MyFirstJava.main(MyFirstJava.java:12)
搜索更多相关主题的帖子: package public Random import xiang 
2014-03-30 21:07
大脸猫xiang
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2014-3-30
得分:0 
哎,低级错误,谢谢楼上
2014-04-01 07:18



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-429405-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.019226 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved