实现加载和列表功能

Implement a load and list function

我的大学给了我这段预设代码,并被告知要从中实现一个加载方法和一个列表方法。但是我目前不确定如何填写空白。我通常不擅长编程,但是在截止日期之前的压力让我忘记了简单的一点 things.This 是我项目第一个增量的最后部分。

我将如何实现加载和列表方法来获取文件 customers.txt。

  public static List<Customer> loadCustomers() {
    List<Customer> customers = null; 

    System.out.println("loadCustomers");
    return customers;
}

我的 class

顶部也有以下内容
    public static void main(String[] args) {
    Scanner userInput = new Scanner (System.in);
    char choice;

    List<Customer> customers=loadCustomers(); 

我不确定我是否理解正确。我猜有两种不同的东西:

  1. 正在将 customers.txt 中的客户列表加载到列表中
  2. 在此方法中返回该客户列表。

要解决此问题,您必须使用以下步骤进行分析求解:

  1. 打开并解析 customers.txt 文件
  2. 对于每个客户,将他们添加到您的 customers 列表
  3. 读完文件的最后一行(或最后一位客户)后,关闭文件,然后 return 列表。

您将必须证明您在尝试解决此问题时已经做了什么 - 所以我不会 post 任何代码。但是上面的工作流程告诉你如何解决这个问题。

此外,不确定为什么方法签名需要是静态的 - 没什么不好 - 但为什么它是实例方法?