无法在我的数组中输入数据

时间:2017-10-07 22:40:51

标签: java arrays

继续说“不兼容的类型String []无法转换为字符串”

我有什么不对吗?

public class TimeCard {
    private int employeeNum;
    private String[] clockInTimes = new String[14];
    private String[] clockOutTimes = new String[14];
    private float[] decimalClockIn = new float[14];
    private float[] decimalClockOut = new float[14];
    private float[] timeElapsed =  new float[14];

    public String getClockInTimes()
    {   //im getting the error here
        return clockInTimes;
    }

    public void setClockInTimes(String[] value)
    {    //getting the error here
        clockInTimes = value;
    }  
}

现在更新它不会让我在数组中输入一个字符串。

我试图这样做:

   public class TestTimeCard {

     /**
     * @param args the command line arguments
     */
     public static void main(String[] args) {
     Scanner reader = new Scanner(System.in);

     TimeCard josue = new TimeCard();

     System.out.println("Enter Monday Clock In Times:");
     josue.setClockInTimes(reader.next());
    }
  }

1 个答案:

答案 0 :(得分:0)

您正在返回数组,但返回类型定义为字符串。

public String[] getClockInTimes()
    {   //im getting the error here
        return clockInTimes;
    }