为什么Arraylist<>;。子列表()未映射到用户定义的数据类型arraylist<>;? import java.io.*; 导入java.util.*; 公共课卡 { 私有int值; 私人诉讼; 公共卡() { 数值=0; 诉讼='0'; } 私有void setValue(int值) { 这个值=值; } 私人诉讼(刑事诉讼) { 这套衣服; } 公共int getValue() { 返回值; } 公用字符集() { 反诉; } 公共卡[]dealCards(int userCount) { intn=(userCount*2)+5; ArrayList pack=新的ArrayList(52); 对于(int i=0;i

为什么Arraylist<>;。子列表()未映射到用户定义的数据类型arraylist<>;? import java.io.*; 导入java.util.*; 公共课卡 { 私有int值; 私人诉讼; 公共卡() { 数值=0; 诉讼='0'; } 私有void setValue(int值) { 这个值=值; } 私人诉讼(刑事诉讼) { 这套衣服; } 公共int getValue() { 返回值; } 公用字符集() { 反诉; } 公共卡[]dealCards(int userCount) { intn=(userCount*2)+5; ArrayList pack=新的ArrayList(52); 对于(int i=0;i,java,arraylist,collections,Java,Arraylist,Collections,,您可以按如下方式修复它们: pack.sublist(0,n)找不到符号错误 dealCards(userCount)似乎抛出找不到符号 错误 1-pack=pack的行。子列表(0,n)找不到符号错误 出现 这是一个输入错误用法:pack=pack.subList(0,n); 2-返回时arraylist无法转换为卡片[] 子列表返回另一个列表。将包声明为: Cards[] newTable = new Cards().dealCards(userCount); //3 现在,您的主屏幕将

,您可以按如下方式修复它们:

pack.sublist(0,n)找不到符号错误

dealCards(userCount)似乎抛出找不到符号 错误

1-pack=pack的行。子列表(0,n)找不到符号错误 出现

这是一个输入错误用法:
pack=pack.subList(0,n);

2-返回时arraylist无法转换为卡片[]

子列表
返回另一个列表。将包声明为:

Cards[] newTable = new Cards().dealCards(userCount); //3
现在,您的主屏幕将如下所示:

Cards cards = new Cards();
cards.dealCards(newTable);
publicstaticvoidmain(字符串[]args){
int userCount=2;
卡片=新卡片();
卡片新表[]=新卡片[(用户数*2)+5];
列表dealCards=cards.dealCards(新表);
对于(int i=0;i<(userCount*2)+5;i++){
System.out.println(dealCards.get(i).getValue()+dealCards.get(i).getSuit());
}
}

1-pack=pack的行。子列表(0,n)找不到符号错误出现。
子列表
使用大写字母L。可以工作,但我们可以将存储列表存储到数组中。@NithinK Yes,使用。请阅读文档。dealCards返回值(数组)这里不使用它。应该吗?我已经做了相应的更改。@markspace ya该名称来自我测试代码时使用的一个类
return pack.toArray(new Cards[0]); //2
Cards[] newTable = new Cards().dealCards(userCount); //3
List<Cards> pack = new ArrayList<>(52);
public List<Cards> dealCards(Cards[] newTable) {
Cards cards = new Cards();
cards.dealCards(newTable);
public static void main(String[] args) {
    int userCount = 2;
    Cards cards = new Cards();
    Cards newTable[] = new Cards[(userCount * 2) + 5];
    List<Cards> dealCards = cards.dealCards(newTable);
    for (int i = 0; i < (userCount * 2) + 5; i++) {
        System.out.println(dealCards.get(i).getValue() + dealCards.get(i).getSuit());
    }
}