PROGRAMMING LANGUAGE/JAVA
[JAVA 개념] 길이 관련 메소드 사용법(length, length(), size())
EARTH_ROOPRETELCHAM
2022. 2. 20. 17:05
728x90
반응형
length
배열의 길이를 알고자 할 때 사용
String[] cars = {"Volvo", "BMW", "Ford", "Mazda"};
System.out.println(cars.length);
// Outputs 4
length()
String과 관련된 객체의 길이를 알고자 할 때 사용
- String, StringBuilder ..
String txt = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
System.out.println("The length of the txt string is: " + txt.length());
size()
Collection 객체의 길이를 알고자 할 때 사용
- ArrayList, Set ..
List<Integer> cars = new ArrayList<>();
cars.size();
참고 자료
728x90
반응형