java - Type mismatch: cannot convert from Class<capture#1-of ?> to Class<?>[] -
what mean, next error message:
type mismatch: cannot convert class<capture#1-of ?> class<?>[]
the code following:
class<?>[] encoderclass; class<?>[] encoderclasses = new class<?>[] { encoder1.class, encoder2.class, encoder3.class }; for(int i=0; i<encoderclasses.length; ++i) { encoderclass = encoderclasses[i]; // <------ error here }
update
oh, silly mistake, thanks....
you're attempting assign single class element class array (different types per error message). instead assign each individual element in for
loop
encoderclass[i] = encoderclasses[i];
ensuring array initialized avoid npe
in assignment
class<?>[] encoderclass = new class<?>[3];
for simplicity replace entire loop with
encoderclass = arrays.copyof(encoderclasses, encoderclasses.length);
java reflection syntax-error
No comments:
Post a Comment