标题:编译错误,需要标识符
只看楼主
大脸猫xiang
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2014-3-30
结帖率:33.33%
已结贴  问题点数:10 回复次数:3 
编译错误,需要标识符
ackage day0415;
import java.util.Arrays;

public class CardsPractice {
    public static void main(String[] args) {
        Card[] cards = new Card[54];
        int i=0;
        for(int rank = Card.THREE;rank<=Card.DEUCE;rank++){
            cards[i++] = new Card(Card.DIAMOND,rank);
            cards[i++] = new Card(Card.CLUB,rank);
            cards[i++] = new Card(Card.HEAT,rank);
            cards[i++] = new Card(Card.SPADE,rank);
        }
        cards[i++] = new Card(Card.JOKER,Card.BLACK);
        cards[i++] = new Card(Card.JOKER,Card.COLOR);//生成牌
    }
    System.out.println(cards.lenth);
}
class Card{
    private int rank;//点数
    private int suit;//花色
    /** 方块*/
    public final static int DIAMOND = 0;
    /** 梅花*/
    public final static int CLUB = 1;
    /** 红桃*/
    public final static int HEAT = 2;
    /** 黑桃*/
    public final static int SPADE = 3;
    /** 王*/
    public final static int JOKER = 4;
   
    public final static int THREE = 0;
    public final static int FOUR  = 1;
    public final static int FIVE = 2;
    public final static int SIX = 3;
    public final static int SEVEN = 4;
    public final static int EIGHT = 5;
    public final static int NINE = 6;
    public final static int TEN = 7;
    public final static int JACK = 8;
    public final static int QUEEN = 9;
    public final static int KING = 10;
    public final static int ACE = 11;
    public final static int DEUCE = 12;
    public final static int BLACK = 13;
    public final static int COLOR = 14;
   
    Card(int suit,int rank){
        this.suit = suit;
        this.rank = rank;
    }
    public int getSuit(){
        return this.suit;
    }
    public int getRank(){
        return this.rank;
    }
}

问题出在System.out.println(cards.lenth);
编译提示需要标识符,没想明白错在哪里?
搜索更多相关主题的帖子: public import 
2014-04-15 06:14
hhwz
Rank: 13Rank: 13Rank: 13Rank: 13
等 级:贵宾
威 望:87
帖 子:687
专家分:4502
注 册:2011-5-22
得分:10 
System.out.println(cards.lenth);要加在方法体里
2014-04-15 11:02
大脸猫xiang
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2014-3-30
得分:0 
还是不太明白,是放的位置错了吗?
2014-04-15 21:09
大脸猫xiang
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2014-3-30
得分:0 
我明白了,是要放到main()方法里,谢谢指点
2014-04-15 21:23



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




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

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