我是靠谱客的博主 火星上灯泡,这篇文章主要介绍Groovy~Groovy数据类型,现在分享给大家,希望可以做个参考。

一、内置数据类型

  • byte:字节值
  • short:短整型
  • int:整数
  • long:长整型
  • float:32位浮点数
  • double:64位浮点数
  • char:单个字符文字
  • Boolean:布尔值
  • String:字符串形式表示的文本

二、取值范围

类型范围
byte-128 ~ 127
short-32,768 ~ 32,767
int2,147,483,648 ~ 147,483,647
long-9,223,372,036,854,775,808 ~ +9,223,372,036,854,775,807
float1.40129846432481707e-45 ~ 3.40282346638528860e + 38
double4.94065645841246544e-324d ~ 1.79769313486231570e + 308d

三、数字类型的使用

class FirstTest{
    static void main(String[] args) {
        int x = 5;
        long y = 100L;
        double b = 10.5e40;
        BigInteger bi = 30g;
        BigDecimal bd = 3.5g;
    }
}

最后

以上就是火星上灯泡最近收集整理的关于Groovy~Groovy数据类型的全部内容,更多相关Groovy~Groovy数据类型内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(119)

评论列表共有 0 条评论

立即
投稿
返回
顶部