Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- *
- */
- 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());
- }
- }
- public static void main(String[] args){
- ...
- System.out.println(song1.process());
- ...
- }
- public String process(){
- return "Length is " + songLine.length();
- }
- public void process(){
- System.out.println("Length is " + songLine.length());
- }
- public Integer process() {
- return songLine.length();
- }
Add Comment
Please, Sign In to add comment