gpt4 book ai didi

java - com.SearchPlayer 不是一个封闭类

转载 作者:行者123 更新时间:2023-12-01 17:59:58 25 4
gpt4 key购买 nike

我正在从 SerchPlayer 类创建我的播放器的类对象,它生成 =“com.SearchPlayer 不是一个封闭类”当我运行我的项目时出现错误

玩家player = new Player();

import cz.msebera.httpclient.android.BuildConfig;
import java.io.Serializable;
import java.util.ArrayList;

public class SearchPlayer {
public ArrayList<Player> Player;

public class Player implements Serializable {
public static final long serialVersionUID = 1;
public String FirstName;
public String LastName;
public String Role;
public String personid;
public String playerImg;

public Player() {
this.personid = BuildConfig.VERSION_NAME;
this.playerImg = BuildConfig.VERSION_NAME;
this.FirstName = BuildConfig.VERSION_NAME;
this.LastName = BuildConfig.VERSION_NAME;
this.Role = BuildConfig.VERSION_NAME;
}
}
}

最佳答案

您的内部类不是静态的,它需要其封闭类的实例来创建对象。尝试一下

SearchPlayer x = new SearchPLayer();
SearchPlayer.PLayer y = x.new PLayer();

关于java - com.SearchPlayer 不是一个封闭类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41787298/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com