What is the difference between CharSequence[] and a String[]?

后端 未结 7 1400
野的像风
野的像风 2020-12-24 10:32

What is the difference between CharSequence[] and String[]?

7条回答
  •  一向
    一向 (楼主)
    2020-12-24 11:04

    Here is my diagram showing how String is a one of several concrete classes implementing the CharSequence interface.

    In particular, StringBuilder is commonly used as a faster alternative to concatenation String objects with the + operator, where thread-safety is not needed.

    The square brackets means an array. So, String[] is an array of String objects, and CharSequence[] is an array of objects that may or may not be String objects but definitely are objects implementing the CharSequence interface.

    See my Answer here and my Answer here for much more discussion.

提交回复
热议问题