3 Replies Latest reply: Aug 13, 2009 4:42 PM by 807580 RSS

    How to turn a number of arrays into an array with an index numbe

    807580
      Hi
      I have 3 arrays called cps1, cps2 and cps3.
      What do I need to do to in order to be able to use the array name (cps_x) in a loop the recognise the index number (x).
      Do I need to do something different in the way I declare and initialise the arrays?
      Or is it more complex?
      What do I need to do in order to make the code below work?

      Thanks for your help


      int x=0;
      double[] cps1= new double[] {75.9042408986955, 52.51153872409542, 0.5, 76.51180919240942, 49.49901260109725, 0.5, 77.70163043426585, 49.67622002009714, 0.5,
      78.35982941912259, 46.537117169241895, 0.5, 78.08136061783705, 45.42324196409971, 0.5, 75.67640278855279, 44.840989015957206, 0.5, 68.73999810198555, 40.942425797959565, 0.5,};
      
      double[] cps2= new double[] {75.9042408986955, 52.51153872409542, 0.5, 76.51180919240942, 49.49901260109725, 0.5, 77.70163043426585, 49.67622002009714, 0.5,
      78.35982941912259, 46.537117169241895, 0.5, 78.08136061783705, 45.42324196409971, 0.5, 75.67640278855279, 44.840989015957206, 0.5, 68.73999810198555, 40.942425797959565, 1,};
      
      double[] cps3= new double[] {75.9042408986955, 52.51153872409542, 0.5, 76.51180919240942, 49.49901260109725, 0.5, 77.70163043426585, 49.67622002009714, 0.5,
      78.35982941912259, 46.537117169241895, 0.5, 78.08136061783705, 45.42324196409971, 0.5, 75.67640278855279, 44.840989015957206, 0.5, 68.73999810198555, 40.942425797959565, 2,};
      for ( x = 1; x <= 3; x = x + 1) {
          
            Arrays.fill(cps_x, 2,5 , 10); //
      }