我寫了如下簡單的代碼。基本上在setString
,我輸入「句子」作爲字符串,並在getString
,它應該返回字符串。當我在Junit中測試時,它說getString
返回null而不是「句子」。Java代碼返回null而不是字符串
public class MyString implements MyStringInterface{
public String str;
//Sets the value of the current string
public void setString(String str){
str = "Sentence";
}
// Returns the current string
public String getString(){
return str;
}
}
您應該使用一個IDE。 – 2014-09-04 02:35:42