初学者求解
请各位高手看看我在个程序的错误是什么原因啊???(谢谢!!)import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class CustomerCareExecutive
{
String executiveName;
int rating;
public void displayDetails()
{
System.out.println(executiveName);
System.out.println(rating);
}
}
class ExecutiveCollection
{
CustomerCareExecutive exObjects[];
public ExecutiveCollection()
{
for(int ctr=0;ctr!=3;ctr++)
{
exObjects[ctr]=new CustomerCareExecutive();
}
exObjects[0].executiveName="Smart Cells Inc";
exObjects[0].rating=Integer.parseInt("30+40");
exObjects[1].executiveName="AlkaTel Inc";
exObjects[1].rating=85;
exObjects[0].executiveName="CellTalk Inc";
exObjects[0].rating=60;
}
public void displayCollection()
{
try
{
for(int ctr=0;ctr!=3;ctr++)
{
exObjects[ctr].displayDetails();//错误在这里????
}
}
catch(ArrayIndexOutOfBoundsException e)
{
System.out.println("Trying to access beyond the length of the array");
}
}
public static void main(String args[])
{
ExecutiveCollection collectionObj;
collectionObj =new ExecutiveCollection();
collectionObj.displayCollection();
System.out.println("All Records displayed");
}
}