确定有main方法啊啊!java.lang.NoSuchMethodError: main Exception in thread "main"

tomato91 2011-05-12 02:08:40
哪位大神能运行一下下面的代码么 ,这代码除了有个内部类,应该没什么特别的了>_< google了很久米有解决诶。

java.lang.NoSuchMethodError: main
Exception in thread "main"


import java.util.Stack;

public class Maze
{
private static byte maze[][] = new byte[12][12];
//private int m_col,m_row;
private static Stack path;
private static int size = 10;// size=row=col

public static void main(String[] args)
{
// TODO Auto-generated method stub
Maze maze1 = new Maze();
maze1.inputMaze();
if(maze1.findPath())
System.out.println("Find Path!");
//outputPath();
else
System.out.println("No Path!");
}

//内部类
static class Position
{
private int col;// = m_col;
private int row;// = m_row;
public Position(int i, int j)
{
// TODO Auto-generated constructor stub
row = i;
col = j;
}
}

private static void inputMaze()
{
byte maze[][] =
{
{0,1,1,1,1,1,0,0,0,0},
{0,0,0,0,0,1,0,1,0,0},
{0,0,0,1,0,1,0,0,0,0},
{0,1,0,1,0,1,0,1,1,0},
{0,1,0,1,0,1,0,1,0,0},
{0,1,1,1,0,1,0,1,0,1},
{0,1,0,0,0,1,0,1,0,1},
{0,1,0,1,1,1,0,1,0,0},
{1,0,0,0,0,0,0,1,0,0},
{0,0,0,0,1,1,1,1,0,0}
};
}

private static boolean findPath()
{
path = new Stack();

//initialize offsets
Position [] offset = new Position [4];
offset[0] = new Position(0,1); //right
offset[1] = new Position(1,0); //down
offset[2] = new Position(0,-1); //left
offset[3] = new Position(-1,0); //up

//initialize wall of obstacles around maze
for(int i = 0; i <= size + 1; i++)
{
maze[0][i] = maze[size+1][i] = 1;
maze[i][0] = maze[i][size+1] = 1;
}

Position here = new Position(1,1);//entrsnce
maze[1][1] = 1; //prevent return to entrance.
int option = 0; //next move
//int lastOption = 3;

//search for a path
while(here.row!=size || here.col!=size)
{
//not at exit , find a neighbor to move to
int r = 0,c = 0;
while(option <= 3)
{
r = here.row + offset[option].row;
c = here.col + offset[option].col;
if(maze[r][c] == 0)
break;
option++;
}

//was a neighbor found?
if(option <= 3) //yes
{
//move to maze[r][c]
path.push(here);
here = new Position(r,c);
maze[r][c] = 1;
option = 0;
}
else
{
if(path.empty())
return false;
Position next = (Position)path.pop();
if(next.row == here.row)
option = 2 + next.col - here.col;
else
option = 3 + next.row - here.row;
here = next;
}
}
return true; //at exit
}

//private static void outputPath()
//{

//}
}
...全文
80 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
tomato91 2011-05-12
  • 打赏
  • 举报
回复
真的不能运行呐~~~~~~~

换其他代码就可以运行,应该不是eclipse的问题吧~

求救啊~~~~~~~~~~~
tomato91 2011-05-12
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 awusoft 的回复:]
在eclipse里可以运行 啊
[/Quote]
啊 这位大哥 你确定可以运行?!难道我的eclipse抽风了= =||||||
awusoft 2011-05-12
  • 打赏
  • 举报
回复
命令行也可以啊..你是不是命令输错了?
awusoft 2011-05-12
  • 打赏
  • 举报
回复
在eclipse里可以运行 啊

62,635

社区成员

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

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