Reputation: 27
This code is asserting that a created class' method which returns a certain value returns the right number. I have to insert my own code where [???]
is currently.
class A { int m() { return 1; } }
public class Exercise {
public static void main(String [] arg) {
A a = [???];
assert a.m() == 2;
}
}
How do I change the return value of the m
method of the class A so it returns 2, not 1?
Upvotes: 1
Views: 652
Reputation: 24229
I suppose you need something like this:
A a = new A() {
@Override
int m() {return 2;}
};
Upvotes: 3