short_Keyword

short Java Keyword with Examples

Key points about short Java Keyword

  • The short keyword is used to declare a variable as a numeric type.
  • short is a signed 16-bit type.
  • It has a range from –32,768 to 32,767.
  • The Short class is a wrapper class for the short primitive type. It defines MIN_VALUE and MAX_VALUE constants representing the range of values for this type.

short Java Keyword Example

Here are some examples of short variable declarations:

short s;
short t;

Here are some examples of short variable declaration and initialization:

short length = 20120;
short flag = 10;

The short keyword can be used to the declared return type of a method as well:

public short getLength() {
    return 20;
}
全部评论

相关推荐

10-15 10:57
已编辑
武昌理工学院 FPGA工程师
狠赚笔第一人:老哥学院本没实习还想拿13k学Java狠赚笔呢
点赞 评论 收藏
分享
10-15 03:05
门头沟学院 Java
CADILLAC_:凯文:我的邮箱是死了吗?
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务