Sign In

[JAVA] 배열 원소의 길이

Created by
  • 무둥
Created at
Category
  1. JAVA
Status
해결
문자열 배열 strlist가 매개변수로 주어집니다. strlist 각 원소의 길이를 담은 배열을 return하도록 solution 함수를 완성해주세요.

◇ 내 답변

class Solution { public int[] solution(String[] strlist) { int[] answer = new int[strlist.length]; for (int i = 0; i < strlist.length; i++) { answer[i] = strlist[i].length(); } return answer; } }
1.
반복문 뺑이...
JS 하다와서 new로 참조형 생성해주는걸 자꾸 잊는다... 생소하다... length도 메소드하고 기본?...이 따로 있는게 어색하다...