为什么Java" String"用大写字母写的类型,而“int”不是? [英] Why is Java "String" type written in capital letter while "int" is not?

查看:226
本文介绍了为什么Java" String"用大写字母写的类型,而“int”不是?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很好奇。为什么我必须用大写字母键入 String myStr 而我用小写字母键入 int aNumba

I am curious. Why do I have to type String myStr with a capital letter whereas I type int aNumba with a lower-case letter?

推荐答案

因为 int 是基本类型,而不是类,因此它与 String 无法直接比较。相应的类类型为 Integer ,根据命名约定<类别拼写/ a>。

Because int is a primitive type, not a class, thus it is not directly comparable to String. The corresponding class type is Integer, spelled according to the class naming conventions.

类似的原始类和类类型对

Similar pairs of primitive and class types are

  • byte vs Byte
  • short vs Short
  • long vs Long
  • float vs Float
  • double vs Double
  • boolean vs Boolean
  • char vs Character

这篇关于为什么Java&quot; String&quot;用大写字母写的类型,而“int”不是?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆