【问题标题】:can i call arraylist methods inside other mehods using (this.name of the arraylist method)我可以使用(arraylist 方法的this.name)在其他方法中调用arraylist 方法吗
【发布时间】:2018-03-27 19:16:08
【问题描述】:

例如,我想创建一个反转arraylist顺序的方法

public void  ReverseOrder (){
    this.reversOrder();
    System.out.println(this);
}

【问题讨论】:

    标签: java arrays arraylist methods call


    【解决方案1】:

    我不知道你为什么要这样做。有没有相同的用例?

    无论如何,如果你想使用ArrayList 对象下的字段,那么你需要在你的类上扩展ArrayList 类,然后你就可以使用this 来做到这一点。如果您想自定义ArrayList 的方法,那么您需要覆盖这些方法。

    【讨论】:

      猜你喜欢
      • 2021-04-07
      • 2015-02-14
      • 1970-01-01
      • 1970-01-01
      • 2022-01-19
      • 1970-01-01
      • 1970-01-01
      • 2016-01-11
      • 1970-01-01
      相关资源
      最近更新 更多