I have a Lazy class defined as the above. I am trying to create a combine method which takes in another Lazy object and combine it with the current Lazy object using the BiFunction to return a new Lazy object. This is what I have so far:
However, when I try to run the code, I get the error which says:
Lazy3.java:70: error: incompatible types: T#1 cannot be converted to T#2
T thisElement = this.get();
where T#1,T#2 are type-variables:
T#1 extends Object declared in class Lazy
T#2 extends Object declared in method <T#2>combine(Lazy<T#2>,BiFunction<? su
Why have you got that boolean called isNull, which is false when your class hasn't been instantiated and true when it has? That is a sure‑fire way to confuse yourself.
You are saying that you are returning a T but in lines 26 and 30, you are trying to return the Supplier<T>. Surely you would write s.get()?
Pease explain what the purpose of the if statement is; how does it differ from line 30?
What will happen if you pass null to line 6?