package com.itheima;
/**
* 8、 先写一个程序,打印从1到100的值。之后修改程序,通过使用break关键词,使得程序在打印到98时退出。然后尝试使用return来达到相同的目的。
* @author 281167413@qq.com
*/
public class Test8 {
public static void main(String[] args)
{
nomDisplay();
breakDisplay();
returnDisplay();
}
public static void nomDisplay()
{
for(int i=1; i<=100; i++)
{
System.out.print(i);
}
System.out.print(" nom end!\n");
}
public static void breakDisplay()
{
for(int i=1; i<=100; i++)
{
if (98 == i)
{
break;
}
System.out.print(i);
}
System.out.print(" break end!\n");
}
public static void returnDisplay()
{
for(int i=1; i<=100; i++)
{
if (98 == i)
{
return;
}
System.out.print(i);
}
System.out.print(" return end!\n");
}
}
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 nom end! 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 break end! 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有