| 类 | 说明 |
|---|---|
| IFBlockGenerator |
这里我们将创建如下内容的类
public class IFBlockGeneratorExample{
public static void main(String[] args){
ifelse("A", 0);
ifelse("A", 1);
ifelse("B", 0);
ifelse("B", 1);
ifelse("C", 0);
ifelse("C", 1);
}
public static void ifelse(String str, int i)
{
if (str.equals("A"))
{
if (i == 0){
System.out.println("str is 'A', i is 0");
}else{
System.out.println("str is 'A', i is not 0");
}
}else if (str.equals("B")){
if (i == 0){
System.out.println("str is 'B', i is 0");
}else{
System.out.println("str is 'B', i is not 0");
}
}else(){
if(i == 0){
System.out.println("str is unknow, i is 0");
}else{
System.out.println("str is unknow, i is not 0");
}
}
}
}
|
Copyright © 2015. All rights reserved.