right doing this:
public class values { list<line> _lines = new arraylist<>(); public class line { public line() { values.this._lines.add(this): } public values get_parent() { return values.this; } } }
this means when have line can values class belongs to, , when have values accessing _lines instance variable can list of lines belong values object.
this works fine , have no problem it, know , there way instances of line created under each class of values without using reflection?
as side note i'm saying without reflection because in old days used avoid reflection because intense on processor, may have changed, still mistrust reflection , try avoid when possible
thanks in advance can provide
edit: may have explained incorrectly wished do, i'm sorry that, here's asking
the above code i'm using now, wish use this:
public class values { public class line { } }
so assuming above scenario, there way without reflection?
values v = new values(); line l1 = v.new line(); line l2 = v.new line(); list<line> = magical way retrieve lines v;
i'm sorry confusion
your _lines
variable has default access modifier meants it's package private docs.
so answer depends. if class accessing variable same package no not need reflection. if it's not either reflection or getter want.
Comments
Post a Comment