Closed junajo10 closed 7 years ago
You can make numShares
visible to the apply
method scope by marking it final
. This doesn't specifically allow an extra argument to apply, but it will solve your immediate problem.
Thanks, but numShares is an argument that i set from another function, i can not fixed as final becuase it must be dynamic.
See below, having a final
variable reference is not the same as having a variable which is constant.
public void getStaticProfile(final int numShares) {
this.service.getDf().apply(new Function<Object,Number>() {
public Number apply(Object value) {
BigDecimal b = new BigDecimal(value.toString());
System.out.println(b);
return b.multiply(new BigDecimal(numShares));
}
});
Hi,
How can i add an extra argument numShares? public void getStaticProfile(int numShares) { this.service.getDf().apply(new Function<Object,Number>() { public Number apply(Object value) { BigDecimal b = new BigDecimal(value.toString()); System.out.println(b); return b.multiply(new BigDecimal(numShares)); } });
Rgds,
JJ