class Solution {
public int solution(int[] array) {
int answer = 0;
return answer;
}
}
class Solution {
public int solution(int[] array) {
int answer = 0;
for (int a : array) {
while (a != 0) {
if (a % 10 == 7) {
answer++;
}
a /= 10;
}
}
return answer;
}
}
import java.util.*;
class Solution{
public int solution(int[] array){
int answer = 0;
String str = Arrays.toString(array);
for (int i = 0; i < str.length(); i++) {
if (str.charAt(i) == '7') {
answer++;
}
}
return answer;
}
}
Arrays.toString() : 배열 모든 요소를 문자로 변환
charAt()
class Solution {
public int solution(int[] array) {
int answer = 0;
String str = "";
// 배열 -> 문자열
for (int i = 0; i < array.length; i++) {
str += array[i];
}
for (int i = 0; i < str.length(); i++) {
if (str.substring(i, i+1).equals("7")) {
answer++;
}
}
return answer;
}
}
String str = "";
str.substring(i, i+1) : 문자열을 하나씩 잘라서