标签:ott ati rgs new drive public while 对象 round
public class Beersong {
public static void main (String[] args){
int beernum =99;
String word = "bottle";
while (beernum>0){
if (beernum == 1){
word = "bootle";
}
System.out.print(beernum+""+word+"of beer on the wall");
System.out.println(beernum+""+"of beer");
System.out.println("Take one down.");
System.out.println("passit around.");
beernum = beernum -1;
if (beernum>0); {
System.out.println(beernum+""+"of beer on wall");
}
{
System.out.println("No more bottles of beer on the wall");
}
}
}
}
2.class Books{
String title;
String author;
}
class BookTestDrive {
public static void main(String args[]){
Books[] myBooks = new Books[3];
int x = 0;
//创建books对象
myBooks[0]=new Books();
myBooks[1]=new Books();
myBooks[2]=new Books();
myBooks[0].title="The Grapes of Java";
myBooks[1].title="The Java Gatsby";
myBooks[2].title="The Java Cookbook";
myBooks[0].author="bob";
myBooks[1].author="sue";
myBooks[2].author="ian";
while(x<3){
System.out.println(myBooks[x].title);
System.out.println("by");
System.out.println(myBooks[x].author);
x=x+1;
}
}
}
标签:ott ati rgs new drive public while 对象 round
原文地址:https://www.cnblogs.com/zwq023/p/14253389.html