当前位置: 首页 > news >正文

宜昌市网站建设app平台运营模式

宜昌市网站建设,app平台运营模式,网络推广策划思路,深圳市招投标交易中心网站与任何程序设计语言一样#xff0c;Java使用条件语句和循环结构确定控制流。本文将简单讲解条件、循环和switch。一、块作用域块(block)#xff0c;即复合语句。是指由一对大括号括起来的若干条简单的Java语句。块确定了变量的作用域。比如#xff1a;public class Code {st…与任何程序设计语言一样Java使用条件语句和循环结构确定控制流。本文将简单讲解条件、循环和switch。一、块作用域块(block)即复合语句。是指由一对大括号括起来的若干条简单的Java语句。块确定了变量的作用域。比如public class Code {static{System.out.println(1);}{System.out.println(2);}public Code(){System.err.println(3);}public static void main(String[]args){new Code();}}注意不能在嵌套的两个块中声明同名的变量。二、条件语句格式1if(condition){statement1statement2........}例如1if(youSalestarget)2{3performanceSatisfactory;4bonus1000;5}格式2if(condition)statement1 else statement2例如if(youSalestarget)performance“Satisfactory”bonus10010*(youSales-target“)elseperformance”Unstatisfactory“bonus0三、循环当条件为true时while循环执行。格式1while(condition)statemnet例如while (balance{balancepayment;double interestbalance*interestRate/100;balanceinterest;years;}格式2do statement while(condition);do{balancepayment;double interestbalance*interestRate/100;balanceinterest;year;System.out.printf(After year %d,your balance is %,.2f%,year,balance);System.out.print(Ready to retire?(Y/N));inputin.next();}while(input.equals(N));}四、确定循环for循环语句是支持迭代的一种通用结构利用每次迭代之后更新的计数器或类似的变量来控制迭代的次数。格式类似如下for(int i0iSystem.out.println(i);例子4个public class ShuZu1 {public static void main(String[]args){int [][] x{{1,2,2,2,2},{3,3,3,3,3},{4,5,-1,17,55}};int resultqiuHe(x);System.out.println(和是result);}public static int qiuHe(int[][]x){int s0;for(int i0;i{for(int j0;j{sx[i][j];}}return s;}}public class ShuZu2 {public static void main(String[]args){int [][] xnew int[7][7];//生成随机数组注意没有返回值另外打印一行字suiJi(x);System.out.println(生成的数组是);//显示数组内容注意没有返回值showArray(x);//取值float resultgetAvg(x);System.out.println(平均数是result);}static float getAvg(int [][] x){float s0;for(int i0;ifor(int j0;jsx[i][j];}}return s/(x.length*x[0].length);}static void suiJi (int[][]x){          //这里我出错了。返回值写了int型不应该的。思考一下。for(int i0;ifor(int j0;jx[i][j](int)(Math.random()*10);}}}static void showArray(int[][]x){        //这里我出错了。返回值写了int型不应该的。思考一下。for(int i0;ifor(int j0;jSystem.out.print(x[i][j]\t);// 给数据空格}System.out.println();//打印换行}}}import java.util.Arrays;public class SuZu3{public static void main(String[] args) {int [] x{2,-1,7,777,6,764,85896,65554,0,874785,417825,74};sort(x,n);for(int i0;iSystem.out.print(x[i]\t);}}//给数组进行选择性排序//调用API进行升序static void sort(int[]x,char Flag){if(AFlag){Arrays.sort(x);}else {for(int i0;ifor(int j0;jint temp0;if(x[j]tempx[j];x[j]x[j1];x[j1]temp;}}}}}}import java.util.Scanner;public class Suzu4 {public static void main(String[] args) {System.out.println(请输入);//这个命令只能紧贴在Scanner scan new Scanner(System.in);的上面或下面才有效。Scanner scan new Scanner(System.in);//System.out.println(请输入);或者放在Scanner scan new Scanner(System.in);的下面String str scan.nextLine();// nextLine才是接收一行char[] s str.toCharArray();// 把字符串转换称一个字符数组scan.close();int letterCount 0;int numberCount 0;int spaceCount 0;int otherCount 0;for (int i 0; i s.length; i) {if (s[i] a s[i] z || s[i] A s[i] Z) {letterCount;} else if (s[i] 1 s[i] 9) {numberCount;} else if (s[i] ) {spaceCount;} else {otherCount;}}System.out.println(字母有 letterCount 个);System.out.println(数字有 numberCount 个);System.out.println(空格有 spaceCount 个);System.out.println(其他有 otherCount 个);}}//ctrlshiftf 是代码格式化//ctrlshifto  是导包五、多重选择switch语句格式类似如下switch(choice)case 1........breakcase 2.......break.........//可以再来几个case(用break结束一下)default.......break注意case标签可以是* 类型为char、byte、short或int的常量表达式。* 枚举常量
http://wiki.neutronadmin.com/news/166925/

相关文章:

  • 导航网址网站怎么做品牌策划全案公司
  • pxhere素材网站品牌推广和品牌营销
  • 广西城乡住房建设厅网站首页wordpress网站资源
  • 电子商务网站建设好么手机网站二级导航菜单
  • jq特效网站模板用vscode做网站
  • 青岛城阳网站制作东莞网络推广服务商
  • 华为免费企业网站建设深圳网站设计兴田德润信任高
  • 手机网站前端写法电子商务seo是指什么意思
  • 建设网站站点有哪些步骤设计 企业网站
  • 那个网站做logo兼职wordpress编辑文章更新失败
  • 百度投诉电话人工服务总部苏宁网站优化与推广
  • 工业设计网站哪个最小程序商城哪家好些
  • 电子商务网站设计原理实践报告山西省建设执业资格注册中心网站
  • 旅游网站制作百度云注册一个公司需要几个人
  • 做网站是那个语言写的wordpress响应式按钮
  • 网站推广计划书包含哪些内容免费的crm系统推荐
  • 邢台网站设计哪家好网站免费的不用下载
  • 专业零基础网站建设教学服务东莞常平二手房价最新消息
  • 沈阳网站建设培训班石家庄网站建设外贸
  • 重庆企业品牌网站建设合肥营销网站建设
  • 厦门门户网站制作服务商广州东莞网站建设
  • 海口网站运营托管咨询优定软件网站建设
  • 网站建设怎么骗人网站建设360元起全包
  • 长春做网站外包网站建设技术人员
  • 建设网站怎么入账北京市住房与建设厅官方网站
  • 婚纱摄影网站建设方案湖南建设工程信息网官网
  • 一 网站建设的目的和目标上海突然传来噩耗
  • 传销网站建设衡水建网站费用
  • 做网站需要招聘内容仿站违法吗
  • 郑州网站推广方法做网站好还是做安卓app好