Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Help needed regarding "recursive method execution"

843789Aug 18 2010 — edited Aug 20 2010
Hi everybody,m a beginner ,while trying to execute the following code in the output i can't getthe symbol ( ' ) correctly printed ,plz lemme know where m i at fault-

class Song{
public static void lyrics(int n){

if(n==1){
System.out.println("No bottles of beer on the wall,; no bottles of beer, ya' can?t take one down,ya' can?t pass it around, 'cause there are no more bottles of beer");
}
else{
System.out.println(n+" bottles of beer on the wall," + n + "bottles of beer, ya? take one down, ya?pass it around," + (n-1)+" bottles of beer on the wall.");
lyrics(n-1);
}

}
public static void main(String[] args)
{
lyrics(3);
}
}

Edited by: basant1988 on Aug 18, 2010 2:26 AM

Edited by: basant1988 on Aug 18, 2010 2:37 AM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 17 2010
Added on Aug 18 2010
10 comments
167 views