"Making" an object in a constructor

K

Ken K

I have the following situation:
Class A implements AI
Class B has a method public AI x();
I want to extend A (or implement an extension of AI) to get Class C
with a constructor such that the instantiation constructed equals (new
B()).x().
This won't be circular, as B does not use this constructor to get its
A.

I've done something close by creating Class C {
private AI a;
C {a = new B().x();}
public A getA () {return a;}
}

I was looking for a solution that doesn't require the psuedoproperty
getA. I could also make a public and do new C().a. Still not quite
(A)(new C()).

Any ideas how I can make this work?

Ken
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,268
Latest member
AshliMacin

Latest Threads

Top