Is it possible to make a method in a Scala class extending class A being called through another class B extending class A and implementing the trait?
public class A {
public int foo(int someData) {
return -1;
}
}
If I would extend the trait with a Scala class the method from the trait would be called. In java it doesn't.
trait T extends A {
override def foo(int: someData) = {
if data < 10 {
return data * 2
} else {
return 0
}
}
}
This is the class I am calling foo() from:
public class B extends A implements T {}
This is supposed to print 44 not -1
public class Main {
B b = new B();
System.out.println(b.foo(22));
}