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

深圳排名网站网页制作分工明细

深圳排名网站,网页制作分工明细,做自己的网站给人的启发,高端网站开发秦帝目录 一、空格截断问题#xff1a;二、next()、nextInt()、nextDouble()等nextXxx()与nextLine()连用、混用的问题#xff1a;问题描述#xff1a;代码演示问题问题原因#xff1a;解决办法#xff1a;示例代码#xff1a; 最后 Java中使用键盘录入#xff0c;尤其是通过… 目录 一、空格截断问题二、next()、nextInt()、nextDouble()等nextXxx()与nextLine()连用、混用的问题问题描述代码演示问题问题原因解决办法示例代码 最后 Java中使用键盘录入尤其是通过Scanner类有时会遇到几个常见问题以下是一些问题及其解决方法 一、空格截断问题 当使用Scanner的next()方法读取带有空格的字符串时输入会在遇到空格时被截断。解决这个问题应该使用nextLine()方法来读取整行输入包括空格。 示例代码 Scanner scanner new Scanner(System.in); String input scanner.nextLine(); // 使用nextLine读取整行输入二、next()、nextInt()、nextDouble()等nextXxx()与nextLine()连用、混用的问题 问题描述 键盘还未输入字符代码直接跳到下一个next方法略过了nextLine()方导致接收到的字符串为空。 代码演示问题 // 创建对象Scanner scanner new Scanner(System.in);// nextInt()System.out.println(输入数字);int i scanner.nextInt();System.out.println(scanner.nextInt:i);// nextLine()System.out.println(输入字符串);String s scanner.nextLine();System.out.println(scanner.nextLine:s);// nextDouble()System.out.println(输入数字);double d scanner.nextDouble();System.out.println(scanner.nextDouble:s);// nextLine()System.out.println(输入字符串);String s2 scanner.nextLine();System.out.println(scanner.nextLine:s2);// next()System.out.println(输入字符串);String s3 scanner.next();System.out.println(scanner.next:s3);// nextLine()String s4 scanner.nextLine();System.out.println(scanner.nextLine:s4);问题原因 如果在同一个Scanner实例中混用了nextXXX()方法如nextInt()、nextDouble()和nextLine()可能会遇到意料之外的行为。这是因为nextInt()等方法不会读取换行符导致后续的nextLine()直接读取之前留下的换行符。 解决办法 在使用完非nextLine()方法后添加一个额外的nextLine()来消费掉换行符。 示例代码 // 创建对象Scanner scanner new Scanner(System.in);// nextInt()System.out.println(输入数字);int i scanner.nextInt();System.out.println(scanner.nextInt:i);// 添加一个额外的nextLine()来消费掉换行符scanner.nextLine();// nextLine()System.out.println(输入字符串);String s scanner.nextLine();System.out.println(scanner.nextLine:s);// nextDouble()System.out.println(输入数字);double d scanner.nextDouble();System.out.println(scanner.nextDouble:s);// 添加一个额外的nextLine()来消费掉换行符scanner.nextLine();// nextLine()System.out.println(输入字符串);String s2 scanner.nextLine();System.out.println(scanner.nextLine:s2);// next()System.out.println(输入字符串);String s3 scanner.next();System.out.println(scanner.next:s3);// 添加一个额外的nextLine()来消费掉换行符scanner.nextLine();// nextLine()String s4 scanner.nextLine();System.out.println(scanner.nextLine:s4); 最后 如果感觉有收获的话点个赞 吧。 ❤️❤️❤️本人菜鸟修行期如有错误欢迎各位大佬评论批评指正 如果觉得这篇文对你有帮助的话也请给个点赞、收藏下吧非常感谢!
http://www.pierceye.com/news/811537/

相关文章:

  • 福建网站建设网wordpress批量替换标签
  • 网站建设 海外房产商标注册证查询
  • 门户网站建设要求易申建设网站
  • 现在创业什么行业最好seo全网营销公司
  • 网站 域名 授权服务器 分布式网站模板英文
  • wordpress 二维码插件搜索引擎优化的方法
  • 国外申请域名的网站CC wordpress 攻击
  • 能发外链的网站中国机械加工网加热炉节能
  • 个人网站推广 公司网站地址栏小图标
  • 网站 如何 备案营销型网站建设便宜
  • 从网上怎么做网站营销做算命类网站违法吗?
  • 口碑好的网站开发公司哪家最专业网站优化关键词是怎么做的
  • 一级a做爰片免费网站天天看专业网站建设公司推荐
  • 套模版做的网站好优化吗win10系统优化软件
  • 红酒营销 网站建设网站建设多少钱一年
  • 公众号注册入口官网seo排名的影响因素有哪些
  • 化妆品网站素材wordpress广告插件中文
  • 设计iphone手机网站网站开发怎么才能接到私活
  • 做网站美工排版提升学历英语翻译
  • 旅游网站建设服务对象微信第三方做网站需要费用吗
  • 能下载的网站soap公司网站
  • 肇庆网站推广排名花都网页设计
  • 网站后台素材wordpress适用linux
  • 开发一个app大概需要多少钱seo按照搜索引擎的什么对网站
  • 比较好的网站建设公司电话珠海开发网站公司
  • 响应式网站怎么做无缝轮播图网站域名在哪里
  • 大连网站建设设计公司哪家好临海市城乡建设规划局网站
  • 福州商城网站建设网站建设的域名和空间价位
  • 如何做外卖网站网页设计照片
  • 长沙河西做网站自己做的网站怎么设置文件下载