Monday 15 September 2014

java - android random floats returning null -


I am trying to generate 10 random places on a surface view to attract 10 circles. The codes given below provide a random float value for X and Y coordinates, but I keep getting a Nalpointer exception at random value assignment and why not understand it.

  rndx = new float [10]; RDY = new float [10]; For (int i = 0; i & lt; rndX.length; i ++) {// random x and y value rndX [i] = (float) generator.nxInt (surface.getWidth ()); Rndy [i] = (float) generator.xitINt (surface.getight ()); }    

The following tasks are just fine.

  float [] rndX = new float [10]; Float [] rndY = new float [10]; Int width = 100; Intensity height = 100; Random Generator = New Random (System.currentTimeMillis ()); For (int i = 0; i   

Your NullPointerException might be the reason that there is no such surface or generator variable Initial

No comments:

Post a Comment