2017-10-07 8 views
-1

"互換性のない型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()); 
    } 
    } 

答えて

0

あなたは配列を返すされているが、戻り値の型は単なる文字列として定義されます。

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

ありがとう!私はあなたがそれを言ったようにそれを修正した、それは誤りを示さない。 –

+0

回答としてマークしてください。 –

関連する問題