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

做设计兼职的网站有哪些上海网站建设包括哪些

做设计兼职的网站有哪些,上海网站建设包括哪些,网站做专题,汕头网页建站模板在本教程中#xff0c;我们将看到将Java中的String转换为int#xff08;或Integer#xff09;的各种方法。 您可以使用以下任何一种方式#xff1a; –使用Integer.parseInt#xff08;string#xff09; –使用Integer.valueof#xff08;string#xff09; –使用…在本教程中我们将看到将Java中的String转换为int或Integer的各种方法。 您可以使用以下任何一种方式 –使用Integer.parseIntstring –使用Integer.valueofstring –使用Apache Commons NumberUtils.toIntstring –使用Apache Commons NumberUtils.createIntegerstring –使用Guava库的Ints.tryParsestring方法 –使用Integer.decodestring –使用新的整数字符串 使用Integer.parseIntstring String empId1 1001; int intEmpId1 Integer.parseInt(empId1); System.out.println(intEmpId1);Output : 1001在以下情况下Integer.parseInt将引发NumberFormatException / Alphabets in the input.Integer.parseInt(100AB);//Input number is greater than the Integer range.Integer.parseInt(2147483648);//Number with decimalInteger.parseInt(1.1); //empty StringInteger.parseInt(); //Blank spaceInteger.parseInt( );使用Integer.valueofstring String empId2 2001;Integer integerEmpId2 Integer.valueOf(empId2); System.out.println(integerEmpId2);Output : 2001使用Apache Commons NumberUtils.toIntstring String empId3 3001; int intEmpId3 NumberUtils.toInt(empId3); System.out.println(intEmpId3);Output : 3001int intEmpId4 NumberUtils.toInt(null); System.out.println(intEmpId4);Output : 0int intEmpId5 NumberUtils.toInt(1001ABC); System.out.println(intEmpId5);Output : 0int intEmpId6 NumberUtils.toInt(1001ABC, 10); System.out.println(intEmpId6);Output : 10使用Apache Commons NumberUtils.createIntegerstring String empId4 4001; Integer integerEmpId7 NumberUtils.createInteger(empId4); System.out.println(integerEmpId7);Output : 4001使用Guava库的Ints.tryParsestring方法 String empId5 5001; Integer integerEmpId8 Ints.tryParse(empId5);System.out.println(integerEmpId8);Output : 5001使用Integer.decodestring String empId6 6001; Integer integerEmpId9 Integer.decode(empId6); System.out.println(integerEmpId9);Output : 6001使用新的整数字符串 String empId7 7001; Integer integerEmpId10 new Integer(empId7); System.out.println(integerEmpId10);Output : 7001但是请记住从Java9开始不推荐使用此Integer构造函数。 完成程序 package com.blogspot.javasolutionsguide.stringtointexample;import org.apache.commons.lang3.math.NumberUtils; import com.google.common.primitives.Ints;public class StringToInt {public static void main(String[] args) {String empId1 1001;int intEmpId1 Integer.parseInt(empId1);System.out.println(intEmpId1);String empId2 2001;Integer integerEmpId2 Integer.valueOf(empId2);System.out.println(integerEmpId2);String empId3 3001;int intEmpId3 NumberUtils.toInt(empId3);System.out.println(intEmpId3);int intEmpId4 NumberUtils.toInt(null);System.out.println(intEmpId4); int intEmpId5 NumberUtils.toInt(1001ABC);System.out.println(intEmpId5);int intEmpId6 NumberUtils.toInt(1001ABC, 10);System.out.println(intEmpId6);String empId4 4001;Integer integerEmpId7 NumberUtils.createInteger(empId4);System.out.println(integerEmpId7);String empId5 5001;Integer integerEmpId8 Ints.tryParse(empId5);System.out.println(integerEmpId8);String empId6 6001;Integer integerEmpId9 Integer.decode(empId6);System.out.println(integerEmpId9);String empId7 7001;Integer integerEmpId10 new Integer(empId7);System.out.println(integerEmpId10);// Alphabets in the input.Integer.parseInt(100AB);//Input number is greater than the Integer range.Integer.parseInt(2147483648);//Number with decimalInteger.parseInt(1.1); //empty StringInteger.parseInt(); //Blank spaceInteger.parseInt( ); } }使用的依赖项 dependencygroupIdorg.apache.commons/groupIdartifactIdcommons-lang3/artifactIdversion3.9/version /dependencydependencygroupIdcom.google.guava/groupIdartifactIdguava/artifactIdversion16.0.1/version/dependency摘要 因此在本教程中我们看到了 –如何在Java中将String转换为int或Integer。 –在大多数情况下如果需要int或Integer则可以使用Integer.parseInt和Integer.valueOf 分别来自String并希望避免依赖第三方库。 – NumberUtils。 toInt 可用于不希望我们的程序由于NumberFormatException而失败的情况。 翻译自: https://www.javacodegeeks.com/2020/03/how-to-convert-string-to-int-in-java.html
http://www.hkea.cn/news/14556078/

相关文章:

  • 前程无忧网广州网站建设类岗位企业网站建设内容 程序开发
  • 基于php技术的网站开发交互式网站开发
  • 三星智能手表网站wordpress关健词
  • 公司网页网站建seo培训班 有用吗
  • 网站如何做地面推广做设计不能不知道的网站
  • 电商网站设计图优秀平面设计网站
  • 备案成功后多久可以打开网站店面装修设计图片
  • 石家庄做标书的网站微信开放平台账号
  • windows优化工具seo科技网
  • 如何降低网站跳出率西安seo推广公司
  • 青岛营销型网站百度竞价包年推广是怎么回事
  • app制作的网站做外快的网站
  • 网站开发工具最好用双语网站后台怎么做
  • 网站建设哪些会影响价格正确的企业邮箱格式
  • js网站纯英文网站建设
  • 公司如何建设网站中天钢铁 网站建设
  • 网站建设公司济南wordpress weather
  • 网站建设公司河南wordpress建m域名网站
  • 学校门户网站群建设方案素马网站设计公司
  • 陕西建设分行网站怎么用阿里云服务器做网站
  • 海口网站建设设计目前专业做水果的网站
  • 免费做优化的网站中学生做的安全作业网站
  • 网站提示页面设计网站后来功能
  • 比较好的网站建设网站抖音代运营是干嘛的
  • 购物网站制作教程天水市网站建设
  • 找产品代理去哪个网站seo如何优化排名
  • 织梦资源下载站网站模板北京4a广告公司有哪些
  • 网站的二维码怎么做的贵阳制作网站的公司
  • 学习html的网站网页制作模板中文
  • 哔哩哔哩网站建设游戏挂机赚钱一小时20