java - have a char reference an object in an array -


is possible have char point object in array? im trying have characters : +,-,*,/ point index in array.

i aware section below not correct syntax. way of describing wish accomplish.

 public static void main(string[] args) {              operations plus;             operations minus;             operations multiply;             operations divide;     /**********create jumptable*******************/             operations[] jumptable = new operations[255];     /**********add object jumptable************/             jumptable[0] = new addition();             jumptable[1] = new subtraction();             jumptable[2] = new multiplication();             jumptable[3] = new division();     /**********point index in table************/             plus = jumptable[0];             minus = jumptable[1];             multiply = jumptable[2];             divide = jumptable[3];      //this im trying do:     //***************************************      char +;      char -;      '+' = plus      '-' = minus , etc...    //****************************************            double x = double.parsedouble(args[0]);            double y = double.parsedouble(args[1]);           system.out.printf("%f %s %f = %f%n", x, op, y, op.compute(x, y));          }     } 

is possible have char point object in array?

assuming asking: "is possible use char index array", answer "yes possible".

an index expression array can have any type can promoted int; see jls 15.13. , char type can promoted int. (you don't need include typecast make happen. works.)


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -