这是我的歌曲。
/*
*
*/
public class SongApp{
public static void main(String[] args){
Song song1 = new Song();
song1.setsongLine("While my guitar gently weeps.");
song1.display();
song1.process();
Song song2 = new Song();
song2.setsongLine("Let it be");
song2.display();
}
}
这是我的支持者。
/*
*
*/
public class Song{
// data field declaration
private String songLine;
/*sets the value of the data field songLine to input parameter value*/
public void setsongLine(String songLine){
this.songLine = songLine;
} //end method
/*returns the value of the data field songLine */
public String getsongLine(){
return songLine;
} //end method
//method called process
public String process(){
int stringLength = songLine.length();
}
/*displays formatted songLine information to the console window */
public void display(){
System.out.println(songLine);
System.out.println("Length is :" + process());
}
}
因此,我的问题正在采用程序方法,即需要印刷歌曲的长度,然后产生例如Length的产出:9,但我的处理方法似乎一直努力工作。