java中这样定义结构体可以不??

睡在床板下_ 2006-05-28 03:27:14
class MyGraphic
{
public int[][] vetx=new int [7][7];
public int numnode;
public int numedge;
}
public class Kruskal
{
private MyGraphic mygraphic;
public static void main(String []args)
{


FileInputStream infile=null;
try
{
infile=new FileInputStream("open.text");
int data;
int x,y;
mygraphic=new MyGraphic();
mygraphic.numedge=9;
mygraphic.numnode=7;
while((data=infile.read())!=-1)
{
x=data;
data=infile.read();
y=data;
mygraphic.vetx[x][y]=data;
infile.read();
}
}
catch(FileNotFoundException e)
{
System.out.println(e.getMessage());
}
catch (IOException e)
{
System.out.println(e.getMessage());
}

infile.close();
for(i=0;i<7;i++)
for(j=i+1;j<7;j++)
System.out.println(mygraphic.vetx[i][j]);
}

}
...全文
805 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
newman0708 2006-05-28
  • 打赏
  • 举报
回复
你把类当结构体也可以呀,
interhanchi 2006-05-28
  • 打赏
  • 举报
回复
没出错的话,不就是可以的了。

62,623

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧