What is the difference between a Character Array and a String?

后端 未结 10 1142
眼角桃花
眼角桃花 2020-12-10 11:49

Spending my time on high level languages it suddenly occurred to me that I did not know the difference between a Character Array and a String. I think they are the same thin

10条回答
  •  情书的邮戳
    2020-12-10 12:26

    String is a class in java. So it has attributes e.g. length. So when you ask for the size of string it simply returns that instead of computing the value each time. It also other methods e.g. indexOf, substring, etc to make life easy so you don't have to do that yourself.

提交回复
热议问题