<div dir="ltr">Not sure about your question exactly, but everything in Java is passed by reference, and all objects are covariant, so you shouldn't need to do anything.</div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jun 8, 2016 at 6:17 PM, Graeme Geldenhuys <span dir="ltr"><<a href="mailto:mailinglists@geldenhuys.co.uk" target="_blank">mailinglists@geldenhuys.co.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I know this is not a Java forum, but thought maybe somebody here with<br>
Object Pascal and Java knowledge could help (seeing that Java-only<br>
developers might not know what I'm talking about).<br>
<br>
Does Java have an equivalent feature of a Object Pascal language's Class<br>
Reference.<br>
<br>
For Example:<br>
I want to write Java code that does similar to my Object Pascal code<br>
shown below:<br>
<br>
TVisClassRef = class of TVisitor ;<br>
<br>
procedure ExecuteVisitor(const pData: TVisited; const pVisClass:<br>
TVisClassRef);<br>
var<br>
lVisitor: TVisitor;<br>
begin<br>
lVisitor := pVisClass.Create; // <<-- Important Part<br>
try<br>
pData.Iterate(lVisitor);<br>
finally<br>
lVisitor.Free;<br>
end;<br>
end;<br>
<br>
This procedure takes care of the tedious business of creating the<br>
visitor, calling iterate, then freeing the visitor when done. I can pass<br>
in various class references as the second argument (all descendants of<br>
TVisitor), and different class instances will be created and used as needed.<br>
<br>
I would love to know how I could do this in Java.<br>
<br>
Regards,<br>
Graeme<br>
<br>
_______________________________________________<br>
fpc-pascal maillist - <a href="mailto:fpc-pascal@lists.freepascal.org">fpc-pascal@lists.freepascal.org</a><br>
<a href="http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal" rel="noreferrer" target="_blank">http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr">Ryan</div><div dir="ltr">[ERROR]: Your autotools build scripts are 200 lines longer than your program. Something’s wrong.<br></div><div dir="ltr"><div><a href="http://kirbyfan64.github.io/" target="_blank">http://kirbyfan64.github.io/</a><div style="display:inline-block;width:16px;height:16px"> </div></div></div></div></div></div></div></div>
</div>