length / length()
2023. 4. 20. 23:49
🧑🏻💻 자바에서 length 와 length()의 차이
💡 length
➡️ 배열의 길이를 나타내는 속성
int[]arr = {1, 2, 3, 4, 5};
int length = arr.length; // -> 5
💡 length()
➡️ 문자열의 길이를 나타내는 메소드
String str = "Hello, world!";
int length = str.length(); // -> 13
'Java > Method' 카테고리의 다른 글
str.replace(char oldChar, char newChar) (0) | 2023.04.22 |
---|---|
Character.getNumericValue() (0) | 2023.04.22 |
Arrays.toString() / Arrays.deepToString() (0) | 2023.04.21 |
Math.floor() / Math.floorDiv() (0) | 2023.04.17 |
forDigit() 메서드 (0) | 2023.04.17 |