Asaf
Asaf

Reputation: 189

Eclipse Java: Eclipse complains of missing curly brace in class

the following code in eclipse gives a "}" missing in classbody when in eclipse, but compiles perfectly well from the terminal. Any clues?

package quiz;

    public class Session {
        static int currentQuestion = 0;
        private Sentence[] sentences; // for building questions
        private Question[] questions;

        public void generateReport(Session publishSession) {

        }

        public int  getRightQuestionCount() {

        }

        public int getWrongQuestionCount() {

        }

        public int calculatePercent() {

        }
        public Question getQuestionAtIdx(int index) {
            return questions[index];
        }
        public Question getPreviousQuestion() {
            return getQuestionAtIdx(--currentQuestion);
        }
        public Question getNextQuestion() {
            return getQuestionAtIdx(--currentQuestion);
        }


        public void setQuestionAtIdx(int index, Question) {

        } 
    }

Upvotes: 0

Views: 2337

Answers (4)

mcfinnigan
mcfinnigan

Reputation: 11638

Eclipse sometimes gets confused. If the code is syntactically correct, try restarting eclipse.

your code as you pasted above will not compile due to several issues, notably missing parameter names and return values as mentioned above.

Upvotes: 0

I think the problem is here:

public void setQuestionAtIdx(int index, Question) { }

Question has no identifier.

Upvotes: 1

marius
marius

Reputation: 1613

Toward the end, you're declaring a function with two parameters; for the second parameter you specified the type, but no name. Maybe that's it.

public void setQuestionAtIdx(int index, Question <<missing name>>) {

}

Upvotes: 4

ngesh
ngesh

Reputation: 13501

that last method

public void setQuestionAtIdx(int index, Question/*has a missing arguement but only its type*/) {

        } 

so add

public void setQuestionAtIdx(int index, Question question) {

        } 

Upvotes: 1

Related Questions