日期:2014-05-20 浏览次数:20741 次
//StationXY.java package svg.station; public class StationXY { private String name; private int x; private int y; public StationXY(){} public StationXY(String name,int x,int y){ this.name=name; this.x=x; this.y=y; } public String getName() { return name; } public void setName(String name) { this.name = name; } public int getX() { return x; } public void setX(int x) { this.x = x; } public int getY() { return y; } public void setY(int y) { this.y = y; } }
//StationToMap.java package svg.action; import svg.station.StationXY; import com.opensymphony.xwork2.ActionSupport; public class StationToMap extends ActionSupport { /** * */ private static final long serialVersionUID = 1L; StationXY[] sxy = new StationXY[100]; public String execute() throws Exception { for(int i=0;i<100;i++) { sxy[i].setName("stationname");//出错信息提示位置 sxy[i].setX(i); sxy[i].setY(2*i); } System.out.println(sxy[50].getName()); System.out.println(sxy[50].getX()); System.out.println(sxy[50].getY()); return null; } }