这个小程序编译错误看不懂求指导
import java.util.*;
//构造一个道路类
public class Road
{
private int dataLength;//表示数据长度
private int roadCode;//道路编号
private int roadNameSize;//道路名称尺寸
private int roadInformation;//道路相关信息
private String roadName;//道路名称
//初始化道路
public void initialize(int dataLength,int roadCode,int roadNameSize,int roadInformation,String roadName)
{
this.dataLength = dataLength;
this.roadCode = roadCode;
this.roadNameSize = roadNameSize;
this.roadInformation = roadInformation;
this.roadName = roadName;
}
//读取类中数据
public int getDataLength()
{
return dataLength;
}
public int getRoadCode()
{
return dataLength;
}
public int getRoadNameSize()
{
return dataLength;
}
public int getRoadInformation()
{
return dataLength;
}
public String getRoadName()
{
return roadName;
}
//修改类中的数据
public void setDataLength( int dataLength )
{
this.dataLength = dataLength;
}
public void setRoadCode( int roadCode )
{
this.roadCode = roadCode;
}
public void setRoadNameSize( int roadNameSize )
{
this.roadNameSize = roadNameSize;
}
public void setRoadInformation( int roadInformation )
{
this.roadInformation = roadInformation;
}
public void setRoadName( String roadName )
{
this.roadName = roadName;
}
}
class test
{
public static void main(String[] args)
{
Road[] r =new Road[70000];
}
}
[解决办法]
应该吧test类删掉,main方法移到road类中
或者新建一个叫test.java的类,里面放main函数
[解决办法]
main方法要在public申明的类中执行