How StringBuffer behaves When Passing Char as argument to its Overloaded Constructor?

前端 未结 2 1618
心在旅途
心在旅途 2020-12-21 12:12
    StringBuffer sb = new StringBuffer(\'A\');
    System.out.println(\"sb = \" + sb.toString());
    sb.append(\"Hello\");
    System.out.println(\"sb = \" + sb.toS         


        
2条回答
  •  梦毁少年i
    2020-12-21 12:49

    U have used below mentioned constructor.

    public StringBuffer(int capacity)

    Constructs a string buffer with no characters in it and the specified initial capacity.

    Parameters: capacity - the initial capacity.

    see the java doc u don't have any constructor which takes char input param.

提交回复
热议问题