# 객체 조합하기
point 배열 선언 후 객체 생성하는 경우 오류가 나오는데 어떤 부분이 잘못 되었는지 모르겠습니다. 잘못된 접근일까요?
#### CODE <a class='btn btn-default' href='/codes/90532'>Link</a>
```
public class TeamTest {
public static void main(String[] args) {
// 선수 객체 생성
Player kim = new Player("Kim", new int[] { 9, 8, 10 });
Player lee = new Player("Lee", new int[] { 10, 9, 10 });
Player park = new Player("Park", new int[] { 8, 10, 9 });
//point 배열 선언
int[] points01 = {10, 9, 10};
int[] points02 = {8,9,10};
int[] points03 = {8, 9, 9};
//선수 객체 생성
Player Xiao = new Player{"Xiao", points01};
Player Yu = new Player{"Yu", points02};
Player Xui = new Player{"Xui", points03};
// 객체 배열 만들기
Player[] koreaPlayers = { kim, lee, park };
Player[] chinaPlayers = {Xiao, Yu Xui };
// 팀 객체 생성
Team korea = new Team("KOREA", koreaPlayers);
Team china = new Team("CHINA", chinaPlayers);
// 팀 점수 출력
korea.printTeamPoints();
china.printTeamPoints();
}
}
// 팀 클래스
class Team {
// 필드
String nation; // 나라
Player[] players; // 선수들
// 생성자
Team (String str, Player[] arr) {
nation = str;
players = arr;
}
// 메소드
void printTeamPoints() {
int sum = 0;
for (int i = 0; i < players.length; i++) {
sum += players[i].totalPoints();
}
System.out.printf("%s -> %d points\n", nation, sum);
}
}
// 선수 클래스
class Player {
// 필드
String name; // 이름
int[] points; // 득점 현황
// 생성자
Player (String str, int[] arr) {
name = str;
points = arr;
}
// 메소드
int totalPoints() {
int sum = 0;
for (int i = 0; i < points.length; i++) {
sum += points[i];
}
return sum;
}
}
```
#### INPUT
```
```
#### OUPUT
```
/root/var/tmp/2023_04_19_23_24_03_150c7e52/TeamTest.java:14: error: '(' or '[' expected
Player Xiao = new Player{"Xiao", points01};
^
/root/var/tmp/2023_04_19_23_24_03_150c7e52/TeamTest.java:14: error: not a statement
Player Xiao = new Player{"Xiao", points01};
^
/root/var/tmp/2023_04_19_23_24_03_150c7e52/TeamTest.java:14: error: ';' expected
Player Xiao = new Player{"Xiao", points01};
^
/root/var/tmp/2023_04_19_23_24_03_150c7e52/TeamTest.java:14: error: not a statement
Player Xiao = new Player{"Xiao", points01};
^
/root/var/tmp/2023_04_19_23_24_03_150c7e52/TeamTest.java:14: error: ';' expected
Player Xiao = new Player{"Xiao", points01};
^
/root/var/tmp/2023_04_19_23_24_03_150c7e52/TeamTest.java:15: error: '(' or '[' expected
Player Yu = new Player{"Yu", points02};
^
/root/var/tmp/2023_04_19_23_24_03_150c7e52/TeamTest.java:15: error: illegal start of type
Player Yu = new Player{"Yu", points02};
^
/root/var/tmp/2023_04_19_23_24_03_150c7e52/TeamTest.java:15: error: <identifier> expected
Player Yu = new Player{"Yu", points02};
^
/root/var/tmp/2023_04_19_23_24_03_150c7e52/TeamTest.java:15: error: ';' expected
Player Yu = new Player{"Yu", points02};
^
/root/var/tmp/2023_04_19_23_24_03_150c7e52/TeamTest.java:16: error: class, interface, or enum expected
Player Xui = new Player{"Xui", points03};
^
/root/var/tmp/2023_04_19_23_24_03_150c7e52/TeamTest.java:20: error: class, interface, or enum expected
Player[] koreaPlayers = { kim, lee, park };
^
/root/var/tmp/2023_04_19_23_24_03_150c7e52/TeamTest.java:21: error: class, interface, or enum expected
Player[] chinaPlayers = {Xiao, Yu Xui };
^
/root/var/tmp/2023_04_19_23_24_03_150c7e52/TeamTest.java:24: error: class, interface, or enum expected
Team korea = new Team("KOREA", koreaPlayers);
^
/root/var/tmp/2023_04_19_23_24_03_150c7e52/TeamTest.java:25: error: class, interface, or enum expected
Team china = new Team("CHINA", chinaPlayers);
^
/root/var/tmp/2023_04_19_23_24_03_150c7e52/TeamTest.java:28: error: class, interface, or enum expected
korea.printTeamPoints();
^
/root/var/tmp/2023_04_19_23_24_03_150c7e52/TeamTest.java:29: error: class, interface, or enum expected
china.printTeamPoints();
^
/root/var/tmp/2023_04_19_23_24_03_150c7e52/TeamTest.java:30: error: class, interface, or enum expected
}
^
17 errors
```
sehongpark님의 답변
중괄호를 소괄호로 바꿔보센
likethebegin님의 답변
아 제가 잘못 했네요 소괄호로 바꾸기 되었습니다. 알려주셔서 감사합니다!!