java - 如何从其他类访问arrayLists(可能在其他包中)
问题描述
我需要从其他包中的其他类访问我在 me.tylercreator.FallenSurv 主类中创建的 ArrayList。
我有不同的包,但我需要每个类都能够从一个类访问某些 ArraysList。
我试图将它们声明为 public static ,但是我只能在同一个文件中从其他类访问它们。
package me.tylercreator.fallensurv.tracer;
public class MovementTracer implements Listener {
public static ArrayList<String> ar = new ArrayList<String>();
public static ArrayList<Block> blockplaced = new ArrayList<Block>();
public static ArrayList<String> onlineplayerList = new ArrayList<String>();
我需要从其他包中的其他类访问它,例如包 me.tylercreator.fallensurv.spawnmodifier
解决方案
谢谢,但我刚刚发现我的 Eclipse 应用程序很愚蠢,不允许我编写 MovementTracer.ar(原因不明),现在它可以工作了,我正在从不同的包访问数组。!
我很快就会切换到 IntelliJ IDEA ,我认为这更好。
推荐阅读
- angular - 如何从Angular中的验证器错误中获取价值
- authentication - 向具有 LDAP 身份验证的用户授予授权
- c++ - 在声明时使用 val.Class 定义类对象的数组,其中数组在构造函数初始化列表和分配有成员数组的 ptr 成员中
- java - 如何使用 HQL 将 oracle regexp_substr 转换为 PostgreSQL
- html - 如何使表格标题全宽?
- python - 使用自定义 ptransform 时使用数据流运行器构建光束管道时出现递归错误
- sed - 如何在同一行附加变量
- c++ - 专门化模板化超类的类的 C++ 工厂
- neo4j - 没有名称为 apoc.refactor.cloneSubgraphfrompaths 的过程为此数据库实例注册
- react-native - 减少水平滚动视图中图像的大小 React native