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

合肥做网站公五八同城58同城找工作

合肥做网站公,五八同城58同城找工作,局网站内容建设考核,做外贸有哪些好的网站有哪些内容对JDK 8中的新功能的关注理所当然地主要集中在新的语言功能和语法上。 但是#xff0c;对库和API进行了一些不错的添加#xff0c;在本文中#xff0c;我介绍了BigInteger类中添加的四个新方法#xff1a; longValueExact#xff08;#xff09; #xff0c; intValueEx… 对JDK 8中的新功能的关注理所当然地主要集中在新的语言功能和语法上。 但是对库和API进行了一些不错的添加在本文中我介绍了BigInteger类中添加的四个新方法 longValueExact intValueExact shortValueExact和byteValueExact 。 如果BigInteger实例中包含的数字不能以指定的形式在方法的名称中指定提供而又不丢失信息则所有新引入的所有“ xxxxxExact”方法都将引发ArithmeticException 。 BigInteger已经拥有方法intValue和longValue以及从继承自Number的方法shortValue和byteValue 。 如果BigInteger值作为这些类型之一丢失表示中的信息则这些方法不会引发异常。 尽管乍看之下似乎是一种优势但这意味着使用这些方法的结果的代码使用的值不准确而又无法知道信息已丢失。 新的“ xxxxxExact”方法将引发ArithmenticException而不是假装提供丢失大量信息的结果。 以下简单的代码清单演示了“传统”方法该方法以byte short int和long类型显示错误数据而不是引发异常。 相同的代码还演示了新的“ xxxxxExact”方法的使用这些方法会在信息丢失时抛出异常而不是呈现错误的表示形式。 运行此代码的输出紧随该代码之后并说明了BigInteger包含一个值比返回的byte short int或long所表示的信息更多的值时方法如何不同。 BigIntegerDem.java package dustin.examples.jdk8;import static java.lang.System.out; import java.math.BigInteger;/*** Demonstrate the four new methods of BigInteger introduced with JDK 8.* * author Dustin*/ public class BigIntegerDemo {/*** Demonstrate BigInteger.byteValueExact().*/private static void demonstrateBigIntegerByteValueExact(){final BigInteger byteMax new BigInteger(String.valueOf(Byte.MAX_VALUE));out.println(Byte Max: byteMax.byteValue());out.println(Byte Max: byteMax.byteValueExact());final BigInteger bytePlus byteMax.add(BigInteger.ONE);out.println(Byte Max 1: bytePlus.byteValue());out.println(Byte Max 1: bytePlus.byteValueExact());}/*** Demonstrate BigInteger.shortValueExact().*/private static void demonstrateBigIntegerShortValueExact(){final BigInteger shortMax new BigInteger(String.valueOf(Short.MAX_VALUE));out.println(Short Max: shortMax.shortValue());out.println(Short Max: shortMax.shortValueExact());final BigInteger shortPlus shortMax.add(BigInteger.ONE);out.println(Short Max 1: shortPlus.shortValue());out.println(Short Max 1: shortPlus.shortValueExact());}/*** Demonstrate BigInteger.intValueExact().*/private static void demonstrateBigIntegerIntValueExact(){final BigInteger intMax new BigInteger(String.valueOf(Integer.MAX_VALUE));out.println(Int Max: intMax.intValue());out.println(Int Max: intMax.intValueExact());final BigInteger intPlus intMax.add(BigInteger.ONE);out.println(Int Max 1: intPlus.intValue());out.println(Int Max 1: intPlus.intValueExact());}/*** Demonstrate BigInteger.longValueExact().*/private static void demonstrateBigIntegerLongValueExact(){final BigInteger longMax new BigInteger(String.valueOf(Long.MAX_VALUE));out.println(Long Max: longMax.longValue());out.println(Long Max: longMax.longValueExact());final BigInteger longPlus longMax.add(BigInteger.ONE);out.println(Long Max 1: longPlus.longValue());out.println(Long Max 1: longPlus.longValueExact());}/*** Demonstrate BigIntegers four new methods added with JDK 8.* * param arguments Command line arguments.*/public static void main(final String[] arguments){System.setErr(out); // exception stack traces to go to standard outputtry{demonstrateBigIntegerByteValueExact();}catch (Exception exception){exception.printStackTrace();}try{demonstrateBigIntegerShortValueExact();}catch (Exception exception){exception.printStackTrace();}try{demonstrateBigIntegerIntValueExact();}catch (Exception exception){exception.printStackTrace();}try{demonstrateBigIntegerLongValueExact();}catch (Exception exception){exception.printStackTrace();}} }输出 Byte Max: 127 Byte Max: 127 Byte Max 1: -128 java.lang.ArithmeticException: BigInteger out of byte rangeat java.math.BigInteger.byteValueExact(BigInteger.java:4428)at dustin.examples.jdk8.BigIntegerDemo.demonstrateBigIntegerByteValueExact(BigIntegerDemo.java:23)at dustin.examples.jdk8.BigIntegerDemo.main(BigIntegerDemo.java:75) Short Max: 32767 Short Max: 32767 Short Max 1: -32768 java.lang.ArithmeticException: BigInteger out of short rangeat java.math.BigInteger.shortValueExact(BigInteger.java:4407)at dustin.examples.jdk8.BigIntegerDemo.demonstrateBigIntegerShortValueExact(BigIntegerDemo.java:36)at dustin.examples.jdk8.BigIntegerDemo.main(BigIntegerDemo.java:84) Int Max: 2147483647 Int Max: 2147483647 Int Max 1: -2147483648 java.lang.ArithmeticException: BigInteger out of int rangeat java.math.BigInteger.intValueExact(BigInteger.java:4386)at dustin.examples.jdk8.BigIntegerDemo.demonstrateBigIntegerIntValueExact(BigIntegerDemo.java:49)at dustin.examples.jdk8.BigIntegerDemo.main(BigIntegerDemo.java:93) Long Max: 9223372036854775807 Long Max: 9223372036854775807 Long Max 1: -9223372036854775808 java.lang.ArithmeticException: BigInteger out of long rangeat java.math.BigInteger.longValueExact(BigInteger.java:4367)at dustin.examples.jdk8.BigIntegerDemo.demonstrateBigIntegerLongValueExact(BigIntegerDemo.java:62)at dustin.examples.jdk8.BigIntegerDemo.main(BigIntegerDemo.java:102) 如上面的输出所示当返回的类型无法在BigInteger实例中保存信息时名称中带有“ xxxxxExact”的新BigInteger方法将不会显示不正确的表示形式。 尽管异常通常不是我们最喜欢的事情之一但它们总是比获取和使用错误的数据甚至不意识到它是错误的更好。 翻译自: https://www.javacodegeeks.com/2014/04/new-biginteger-methods-in-java-8.html
http://www.pierceye.com/news/642166/

相关文章:

  • 开发中英文切换网站如何做本周热点新闻事件
  • 松江网站建设多少钱网络营销推广的八大核心
  • 郑州做设计公司网站暗网网站
  • ps网站背景图片怎么做学技能的免费网站
  • 企业网站开发软件如何恢复wordpress
  • 用脚手架如何搭建项目做网站大气绿色网站模板
  • 海淀地区网站建设苏州论坛
  • 电影项目做产品众筹哪个网站好网站设计评价标准
  • 上海要做网站怎么卖wordpress主题
  • 废旧建筑模板多少钱一吨seo站内优化培训
  • 您在工信部门备案网站获取的icp备案号plone wordpress
  • 网站怎么用PS做公司电脑做网站
  • 化妆品网站设计思路网站管理规范
  • 内部优惠券网站建站马鞍山网站建设电话
  • 手机可以做3d动漫视频网站广告联盟平台
  • 做了静态网站怎么显示在互联网上度假村网站模板
  • 网站改版提交河北建设工程信息网官
  • 建站宝盒v8破解版下载菜鸟怎么做网站
  • 网站建设课程 考核目的wordpress注册确认信
  • 建设银行网站公告2022国内外重大新闻事件10条
  • 门户网站建设 简报电子工程信息建设网
  • 竞价网站模板网站模板小偷
  • 怎么做视频网站网站建设设计基础
  • 惠州网站建设公司曾做网站需要学习什么知识
  • 网站制作里面链接怎么做建网站要什么工做人员
  • 网站建设费用 会计分录网站用哪些系统做的好
  • 免费建立一个个人网站网站模板怎么引用
  • 网站推广软文公司wordpress里面备份功能在哪里
  • 贵州整站优化seo平台网站建设与开发英文文献
  • 江干区住房和城乡建设局网站北京网站开发的趋势在哪里