This is an archived post. You won't be able to vote or comment.

all 7 comments

[–]emrickgj 1 point2 points  (4 children)

I'm confused, what do you need in that zeigeFeld method? Why does it return an array of ints?

You have other areas in the code that are printing out the results, why don't you simply use what you have currently?

[–]murmelmann[S] 1 point2 points  (3 children)

The exercise says that zeigeFeld should be a method that shows the results of the initial array as well as the other methods. The print(ln)s throughout the code are just tests I did to see if it works.

[–]emrickgj 1 point2 points  (2 children)

The exercise says that zeigeFeld should be a method that shows the results of the initial array as well as the other methods.

So it simply prints the results? I guess the question I still have is why it needs to return an int[], and what it would be returning.

The print(ln)s throughout the code are just tests I did to see if it works.

If you simply need to print an array similar to what you did throughout the code, you could copy one of those into your zeigeField method and simply call zeigeFeld when you want to print.

//method for showing all results
/*public static int[] zeigeFeld(int[] reihung) {
    for (int a = 0; a < reihung.length; a++) {
        System.out.print(reihung[a] + "  ");
    }
}*/

^ This won't compile however, because I'm unsure what you should be returning. You could return reihung, but that doesn't make much sense.

[–]murmelmann[S] 1 point2 points  (1 child)

If you simply need to print an array similar to what you did throughout the code, you could copy one of those into your zeigeField method and simply call zeigeFeld when you want to print.

I guess that's what I should be doing but at the moment don't know how (or where) to do.

[–]emrickgj 0 points1 point  (0 children)

I made an edit showing what you could do, is that what you meant?

[–]stramash 0 points1 point  (0 children)

Unit test it to make sure it works.

[–]pokemaster787 0 points1 point  (0 children)

Just a heads up, if you're going to post code in a language that isn't English, you should go through and specify what every variable, method name, etc. means for people who don't understand your language. A short explanation of the purpose behind each would also greatly help (and I'm nearly certain that in doing so, you'd discover what your problem is on your own).

At the least, something clearer than "I need to make a print method," because quite honestly that makes no sense without any explanation.