hi evry one ,im not used to java and i hate its bad compiler
can any one tell me whay it give me this running time error:array index out of bound!
this is the code were it have the erorr:
public class RotatingBieChart extends JApplet {
int diamter,radius;
int partition;
final int WIDTH = 700, HEIGHT =600;
Color colr;
Color []colors;
public void init() {
setSize(WIDTH, HEIGHT);
diamter=getDiameter();
partition=getNumberOFslice();
// colr=randomColor();
}
private int getNumberOFslice()
{
int x=0;
String dimaeter,partitions;
Boolean notInput2=true;
while(notInput2){
try{
partitions =JOptionPane.showInputDialog(null,"enter number of partitions in the pie chart");
x=Integer.parseInt(partitions);
notInput2=false;
colors =new Color[x];
for(int i=0;i<=colors.length;i++)
{
colors[i]=randomColor(); } }
catch(NumberFormatException nfe){
notInput2=true;
//do nothing just complete the loop
} }//end of while
return x;
}
private Color randomColor()
{ Random rand;
rand=new Random();
colr=new Color(rand.nextInt(256),rand.nextInt(256), rand.nextInt(256));
return(colr);
}
}
the green is were it tell me that there is an erorr in it...
thank you in advance:)