2015-01-05 2 views
-2

이있는 부분을 내가에 문제가 데 생각 : 무슨 일이 일어나고 있는지음악 재생 스크립트 (12) 오류

AudioPlayer.java:3: error: ')' expected AudioPlayer AP = new AudioPlayer(optional Replay = true); ^AudioPlayer.java:3: error: illegal start of type AudioPlayer AP = new AudioPlayer(optional Replay = true); ^AudioPlayer.java:3: error: expected AudioPlayer AP = new AudioPlayer(optional Replay = true); ^AudioPlayer.java:3: error: ';' expected AudioPlayer AP = new AudioPlayer(optional Replay = true); ^AudioPlayer.java:4: error: expected AP.playSong(signlink.findcachedir() + "Music/2.wav"); ^AudioPlayer.java:4: error: expected AP.playSong(signlink.findcachedir() + "Music/2.wav"); ^AudioPlayer.java:4: error: ';' expected AP.playSong(signlink.findcachedir() + "Music/2.wav"); ^AudioPlayer.java:4: error: illegal start of type AP.playSong(signlink.findcachedir() + "Music/2.wav"); ^AudioPlayer.java:4: error: expected AP.playSong(signlink.findcachedir() + "Music/2.wav"); ^AudioPlayer.java:4: error: ';' expected AP.playSong(signlink.findcachedir() + "Music/2.wav"); ^AudioPlayer.java:6: error: expected AP.Stop(); ^AudioPlayer.java:6: error: reached end of file while parsing AP.Stop(); ^12 errors Press any key to continue . . .`

어떤 아이디어 : 여기에 내가 가진 오류입니다

public class AudioPlayer { 
    //play the music 
    AudioPlayer AP = new AudioPlayer([Optional Replay = true]); 
    AP.playSong(signlink.findcachedir() + "Music/2.wav"); 
    //stop the music 
    AP.Stop(); 
} 

를? 무엇이 오류를 일으키는 지, 어떻게 해결할 수 있습니까? 이와 함께이 라인

AudioPlayer AP = new AudioPlayer([Optional Replay = true]); 

를 교체

+0

AudioPlayer 클래스 생성자는 어떤 종류의 매개 변수를 가져 옵니까? –

+0

당신이 가지고있는 것은 유효한 구문이 아닙니다. 자바에서는 그렇게 할 수 없습니다. 대신에 생성자에 부울을 허용하려고합니까? – Makoto

+0

클래스, 인터페이스 또는 enum – jake

답변

-1

시도 :

boolean optionalReplay = true; 
AudioPlayer AP = new AudioPlayer(optionalReplay); 

이 프로그램은이 문장을 이해되지 않습니다 [Optional Replay = true]. 내가 여러분에게주는 것은 Java에 적합한 구문입니다.

참고 : 저는 AudioPlayer 생성자가 Boolean 매개 변수를 사용한다고 가정합니다. 하지만 내가 코드를 작성한 방식에 대해 잘못 생각한 것 같습니다.

+0

오류의 큰 금액을 수정 해 주셔서 감사합니다. 지금은 오류가 8 개까지 내려갔습니다. – jake

+0

시원한 상태에서 upvote하고 받아주세요. 8 가지 오류가 무엇입니까? –

+0

코드를 자세히 살펴보십시오. 이 작업만으로는 문제가 해결되지 않습니다. – Makoto