class Solution {
public int solution(String binomial) {
int answer = 0;
return answer;
}
}
class Solution {
public int solution(String binomial) {
int answer = 0;
String[] str = binomial.split(" ");
for (int i = 0; i < str.length; i++) {
if (str[1].equals("+")) {
answer = (Integer.valueOf(str[0])) + (Integer.valueOf(str[2]));
} else if (str[1].equals("-")) {
answer = (Integer.valueOf(str[0])) - (Integer.valueOf(str[2]));
} else if (str[1].equals("*")) {
answer = (Integer.valueOf(str[0])) * (Integer.valueOf(str[2]));
}
}
return answer;
}
}
어차피 인덱스는 3개이므로, [0], [1], [2] 로 활용 가능함
String[] str = binomial.split(" ");
Integer.valueOf
[참고: 타입 및 형변환](https://velog.io/@baekgom/Java-%ED%83%80%EC%9E%85#2-%EB%AC%B8%EC%9E%90%EC%97%B4-%E2%87%8C-%EC%88%AB%EC%9E%90