inheritance - Get enum size from parent interface in java -
I have an interface By which method is passed the How can we achieve it? with reflection, Dirty demo): ParentInterface and there are several enforcers to implement it:
ChildEnum1 and
ChildEnum2 . I have a method that I pass as the
ParentInterface parameter.
ChildEnum , I want to get this size of anonymity How can I do this? The
values.length () method works only on
enums , but we are going through the caller only in
ParentInterface .
package com.stackoverflow.so21821751; Public Class Test {Interface ParentInterface {void someMethod (); } Stable enum implements ChildEnum1 ParentInterface {FOO, BAR, LOL; @ Override public zero; some method () {// some}} static enum ChildEnum2 ParentInterface {FOO, BAR; @ Override Public Zero Some Method () {// Some}} Public Fixed Zero Main (Last String [] args) {foo (ChildEnum1.BAR); // 3 fu (hair annam 2.fu); // 2} Private Static Zero Foo (Last ParentInterface i) {System.out.println (i.getClass (). GetEnumConstants (). Length); }}
Comments
Post a Comment