0

If my method return an array how can I link for it?

private int[] osszesVizsgalata(int currentFord){
        int[] truefalse = new int[2];
        for(int i = 0; i<currentFord-1;i++){
            if(this.ellenfelValaszai[i] == true){truefalse[1]++;}
            else{truefalse[0]++;}
        }
        return truefalse;
    }

This is my method and I cant call it that I can use both element of truefalse.

osszesVizsgalata(2)[0];

This is my try.

1 Answer 1

3

Declare an array in the client method and initialize it with the result of this method:

public void clientMethod() {
    int currentFord = 2;
    int[] foo = osszesVizsgalata(currentFord);
    //code used for example purposes
    System.out.println(foo[0]);
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.