iteye_12441 2010-04-13 18:46 采纳率: 100%
浏览 169
已采纳

数据类型的几个小问题

  1. 有没有好的输入法能支持驼峰式命名? 也就是说能够方便的输入"toStringOrOther"这样的字符串,而不用去按那个shift键.
  2. String类型是否有长度限制?
  3. 有了数据类型int,还定义一个Integer对象类型干啥?有啥用?
  • 写回答

2条回答 默认 最新

  • 拽拽的初行者 2010-04-13 19:54
    关注

    [color=blue][b]1、没用过,应该没有。要不然那种输入法早就流行了

    2、String有长度限制。String其实是一个char数组,数组的长度用int计数。[/b][/color]

    [code="java"]
    public final class String
    implements java.io.Serializable, Comparable, CharSequence
    {
    /** The value is used for character storage. */
    private final char value[];

    /** The offset is the first index of the storage that is used. */
    private final int offset;
    
    /** The count is the number of characters in the String. */
    private final int count;
    

    //........
    [/code]
    [color=blue][b]
    String的最大长度,就是整形的最大值(因为count是int的)

    3、int是原生数据类型。不是一个类。你在Java类的 结构图中找不到int。Integer是一个类,继承Number,而Number继承Object。所以Integer是一个类,int不是类。

    因此以下语句,无法通过编译!![/b][/color]
    [code="java"]
    int i= 0;
    if(i!= null){
    //......
    }
    [/code]

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?