//while循环
public class For {
public static void main(String[] args) {
int year=2015;
int father=30;
int son=6;
while(father!=son*2){
year++;
father++;
son++;
}
}
}
System.out.println(year+“年,父亲是”+father+“岁,儿子是”+son+“岁,正好是2倍关系!”);
//for循环
public class For {
public static void main(String[] args) {
int year=2015,father=30,son=6;
for( ; ; ){
year++;
father++;
son++;
if(father == son*2){
break;
}
}
System.out.println(year+“年,父亲”+father+“岁,儿子”+son+“岁”);
}
}