整数类shortValue()方法 (Integer class shortValue() method)

  • shortValue() method is available in java.lang package.

    shortValue()方法在java.lang包中可用。

  • shortValue() method is used to return the value denoted by this Integer object converted to type short (by casting).

    shortValue()方法用于返回此Integer对象表示的值,该值转换为short类型(通过强制转换)。

  • shortValue() method is a non-static method, it is accessible with the class object only and if we try to access the method with the class name then we will get an error.

    shortValue()方法是一种非静态方法,只能通过类对象访问,如果尝试使用类名访问该方法,则会收到错误消息。

  • shortValue() method does not throw an exception at the time of conversion from double to short.

    在从double到short转换时, shortValue()方法不会引发异常。

Syntax:

句法:

    public short shortValue();

Parameter(s):

参数:

  • It does not accept any parameter.

    它不接受任何参数。

Return value:

返回值:

The return type of this method is short, it returns a converted (from type integer to short) value represented by this Integer object.

此方法的返回类型为short ,它返回此Integer对象表示的转换后的值(从整数类型到short类型)。

Example:

例:

// Java program to demonstrate the example
// of shortValue() method of Integer class
public class ShortValueOfIntegerClass {public static void main(String[] args) {// Variables initialization
int i1 = 10;
int i2 = 20;
// It returns integer value denoted by this Integer value1 object
// and converted to a short by calling value1.shortValue()
Integer value1 = new Integer(i1);
// Display value1 result
System.out.println("value1.shortValue(): " + value1.shortValue());
// It returns integer value denoted by this Integer value2 object
// and converted to a short by calling value2.shortValue()
Integer value2 = new Integer(i2);
// Display value2 result
System.out.println("value2.shortValue(): " + value2.shortValue());
}
}

Output

输出量

value1.shortValue(): 10
value2.shortValue(): 20

翻译自: https://www.includehelp.com/java/integer-class-shortvalue-method-with-example.aspx

Java Integer类shortValue()方法与示例相关推荐

  1. java long short_Java Long类shortValue()方法与示例

    Long类shortValue()方法shortValue()方法在java.lang包中可用. shortValue()方法用于返回由此Long对象表示的值,该对象转换为short类型(通过强制转换 ...

  2. java中intvalue方法作用_Java Integer类intValue()方法及示例

    整数类intValue()方法intValue()方法在java.lang包中可用. intValue()方法用于返回此Integer对象表示的值,该值转换为int类型(通过强制转换). intVal ...

  3. java annotation class,Java Class类 isAnnotation()方法及示例

    Class类isAnnotation()方法isAnnotation()方法在java.lang包中可用. isAnnotation()方法用于检查此Class对象是否表示注释类型. isAnnota ...

  4. java字符类型的返回值,Java字符类isWhitespace()方法及示例

    Character 类isWhitespace()法isWhitespace()方法在java.lang包中可用. isWhitespace()方法用于检查给定的char值是否为空格,但是它包含空格中 ...

  5. Java Long类shortValue()方法与示例

    长类shortValue()方法 (Long class shortValue() method) shortValue() method is available in java.lang pack ...

  6. Java Double类shortValue()方法与示例

    双类shortValue()方法 (Double class shortValue() method) shortValue() method is available in java.lang pa ...

  7. java日历类add方法_Java日历computeTime()方法及示例

    java日历类add方法 日历类computeTime()方法 (Calendar Class computeTime() method) computeTime() method is availa ...

  8. java日历类add方法_Java日历computeFields()方法及示例

    java日历类add方法 日历类的computeFields()方法 (Calendar Class computeFields() method) computeFields() method is ...

  9. java日历类add方法_Java日历setFirstDayOfWeek()方法与示例

    java日历类add方法 日历类setFirstDayOfWeek()方法 (Calendar Class setFirstDayOfWeek() method) setFirstDayOfWeek( ...

最新文章

  1. 为什么模型复杂度增加时,模型预测的方差会增大,偏差会减小?
  2. 【OpenCV 4开发详解】分割图像——分水岭法
  3. Xamarin iOS教程之键盘的使用和设置
  4. Go web之旅(路由篇)
  5. [云炬创业基础笔记]第七张创业团队测试6
  6. 含有js的英文单词_JavaScript 常用单词整理
  7. ADO.NET常用对象详解之:DataAdapter对象
  8. hadoop学习笔记(四):hdfs常用命令
  9. 互联网应用程序压力测试的那点事
  10. C++原型模式和模板模式
  11. 十八、x86汇编基础
  12. Java环境变量配置
  13. 上海工程技术大学c语言商店存货管理系统,商店存货管理系统.docx
  14. Excel表格中保护公式不被修改
  15. 11 个很少人知道但很有用的 Linux 命令
  16. 多次散射 matlab,一种利用外推获得具有多次散射目标远场rcs的方法
  17. 怎么将视频配套讲义打印出来
  18. java web胖客户端,【转载】:瘦客户端、胖客户端、富客户端
  19. vasp运行报错:问题:POSMAP internalerror: symmetry equivalent atom not found
  20. 【调剂】云南师范大学2021年硕士研究生调剂公告(一)

热门文章

  1. html json to table,javascript - HTML - Convert json to table - Stack Overflow
  2. windows进程管理器_任务管理器就能搞定9成的电脑问题?方法在这里!
  3. Docker容器网络解析
  4. Perl的浅拷贝和深度拷贝
  5. 基于百度语音识别API的Python语音识别小程序
  6. 用户反馈:对 Rafy 开发框架的一些个人建议
  7. 《自顶向下网络设计(第3版)》——导读
  8. Linux的iptables常用配置范例(2)
  9. 25 个精美的后台管理界面模板和布局
  10. Qt 4.7.1 和 Mobility 1.1.0 已发布