我写了如下简单的代码。基本上在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