Moosphan / Android-Daily-Interview

:pushpin:每工作日更新一道 Android 面试题,小聚成河,大聚成江,共勉之~
5.49k stars 778 forks source link

2020-01-08:请说说Java中String.length()的运作原理? #229

Open Moosphan opened 4 years ago

haigendong commented 4 years ago

char array 的长度?不会,来凑个热闹。。

juicelover commented 4 years ago

private final char value[];

public String(char value[]) { this.value = Arrays.copyOf(value, value.length); }

public int length() { return value.length; }

THEONE10211024 commented 4 years ago

mark

FirewingsR commented 4 years ago

return value.length

auxor commented 4 years ago

https://colobu.com/2019/01/04/how-many-charactors-in-a-java-string/

zoomc commented 3 years ago

这问题太无聊了,有时间研究这个,不如学学新技术