Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/374.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在Google应用程序引擎端点中使用扩展的ArrayList_Java_Google App Engine_Google Cloud Endpoints - Fatal编程技术网

Java 在Google应用程序引擎端点中使用扩展的ArrayList

Java 在Google应用程序引擎端点中使用扩展的ArrayList,java,google-app-engine,google-cloud-endpoints,Java,Google App Engine,Google Cloud Endpoints,我正在为Google App Engine创建一个端点,为了简单起见,我需要创建一个定制的ArrayList,但我似乎遇到了麻烦 如果我用这样的东西,一切都很好 public class MyClass { @ElementCollection private List<Person> People; // etc } 公共类MyClass{ @元素集合 私人名单; //等 } 如果我把这个换成 public class PersonList extend

我正在为Google App Engine创建一个端点,为了简单起见,我需要创建一个定制的
ArrayList
,但我似乎遇到了麻烦

如果我用这样的东西,一切都很好

public class MyClass {
    @ElementCollection
    private List<Person> People;
    // etc
}
公共类MyClass{
@元素集合
私人名单;
//等
}
如果我把这个换成

public class PersonList extends ArrayList<Person> {
    // custom methods
}

public class MyClass {
    @ElementCollection
    private PersonList People;
    // etc
}
公共类PersonList扩展了ArrayList{
//自定义方法
}
公共类MyClass{
@元素集合
个人主义者;
//等
}
我得到了错误

PersonList不是受支持的属性类型


我必须坚持第一个实现,还是有办法扩展List类?

首先,我假设您在问题中输入了一个错误,您将该类定义为
PeopleList
,然后声明类型为
PersonList
的成员变量。。。对吧?

如果您的代码也没有该错误,那么您可以使用以下方法:

public class MyClass {
    @ElementCollection
    private List<Person> People;
    // etc
}
People = new PersonList();
其中
个人列表是:

public class PersonList extends ArrayList<Person> {
   // custom methods
}

我不知道为什么我没有想到这样做的铸造方式,但我猜这将工作。我会在今天晚些时候检查后进行验证。谢谢你,我的问题的排版是什么?我想知道我是不是做了什么令人震惊的事。啊,这是个打字错误。我把我的问题看了20遍,没有看到。谢谢你的回答
((PersonList)People).somePersonListMethod();