0 Members and 4 Guests are viewing this topic.
import java.awt.*;import java.applet.*;import java.util.Random; public class sphere extends Applet { public void paint(Graphics g) { Random r = new Random(); int wh = r.nextInt(300); while(true) { Color c = new Color(r.nextInt(256), r.nextInt(256), r.nextInt(256)); g.setColor(c); for (wh = 0;wh>=r.nextInt(300);wh++) { g.fillOval(r.nextInt(1001),r.nextInt(701),wh,wh); } // wh = r.nextInt(300); try { Thread.sleep( 20 ); } catch ( InterruptedException e ) { // do nothing } } }}
for (wh = 0;wh>=r.nextInt(300);wh++) {
int wh = r.nextInt(300);...int wh = r.nextInt(300);
but in a large applet, this kind of optimisation can tell the diference between fitting on a CD, and not fitting on a CD.
Code: [Select]int wh = r.nextInt(300);...int wh = r.nextInt(300);These two lines are a waste of size and CPU. I know that it's only a few bites and under a microsecound, but in a large applet, this kind of optimisation can tell the diference between fitting on a CD, and not fitting on a CD.