
download:+
React 配置化+Serverless 开发个人博客http://www.97yrbl.com/t-727.html
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;
}
}
}
3.class Cat{
int size;
String name;
void bark(){
if(size>60){
System.out.println("Woof!Woof!");
}else if(size>14){
System.out.println("Ruff!Ruff!");
}else{
System.out.println("Yip!Yip!");
}
}
}
class DogTestDrive {
public static void main(String[] args){
Cat one = new Cat();
one.size = 70;
Cat two = new Cat();
two.size = 8;
Cat three = new Cat();
three.size = 35;
one.bark();
two.bark();
three.bark();
}
}
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)