Java 无法使用ArrayList中的对象的方法

Java 无法使用ArrayList中的对象的方法,java,object,arraylist,Java,Object,Arraylist,这是我创建卡片的地方 package javaapplication21; 公务舱卡{ private String Name = null; private String Description = null; private String Type = null; public Card(int i, int j) { if (i == 0) { Type = "Spades"; } else if (i == 1) { Type

这是我创建卡片的地方

    package javaapplication21;
公务舱卡{

private String Name = null;
private String Description = null;
private String Type = null;

public Card(int i, int j) {

    if (i == 0) {
        Type = "Spades";
    } else if (i == 1) {
        Type = "Diamonds";
    } else if (i == 2) {
        Type = "Hearts";
    } else if (i == 3) {
        Type = "Clubs";
    }

    int Value = j;
    if (j == 11) {
        Name = "Jack";
    } else if (j == 12) {
        Name = "Queen";
    } else if (j == 13) {
        Name = "King";
    } else if (j == 1) {
        Name = "Ace";
    } else if (j == 14) {
        Name = "Joker";
    } else {
        Name = "" + Value;
    }

}
公共字符串getDescription(){

}

包javaapplication21;
导入java.util.ArrayList;
公共类JavaApplication21{
公共静态void main(字符串[]args){
ArrayList Deck=新的ArrayList();
对于(int i=0;i<4;i++){
对于(int j=1;j<15;j++){
新卡(i,j);
增加(新卡(i,j));
}
}
System.out.println(Deck.get(5.getDescription());
}
}
我在尝试使用组的索引5中的卡对象的getDescription时遇到错误(找不到符号)。我是编程新手,但我真的不知道问题出在哪里。

get()
ArrayList的
method
返回类型为
object
类和
object
类的对象没有
getDescription()


您应该将其强制转换为
类-
(卡)组。获取(5)
数组列表不知道存储对象的类型。您必须定义类型

ArrayList<Card> deck = new ArrayList<Card>();
ArrayList deck=new ArrayList();

非常感谢。你们帮了我很多。似乎我忘了在第一个ArrayList之后插入,这让我困惑了4天多。再次感谢调试我的代码!!很高兴我能帮助你们。你们可以将我的awnser标记为正确的
    package javaapplication21;
    import java.util.ArrayList;
    public class JavaApplication21 {


        public static void main(String[] args) {
            ArrayList Deck=new ArrayList<Card>();
            for (int i = 0; i < 4; i++) {
                for (int j = 1; j < 15; j++) {
                    new Card(i, j);
                    Deck.add(new Card(i, j));


                }
            }
            System.out.println(Deck.get(5).getDescription());

        }

   }
ArrayList<Card> deck = new ArrayList<Card>();