2011-12-29 116 views
0

由于某些奇怪的原因,我最近在Eclipse中使用Android程序时出现错误。昨晚很好,但今天我得到一个错误。这是有问题的代码:奇怪的未定义方法错误

Class ourClass = Class.forName("com.example.exampleone" + cheese); 
    Intent ourIntent = new Intent(Menu.this, ourClass); 

对于第一线我得到的错误:

The method forName(String) is undefined for the type Class 

对于第二个行我得到的错误:

The constructor Intent(Menu, Class) is undefined 

的代码都很正常,直到今天,当它突然开始说有一个错误

+1

你能复制你的类的输入吗? – 2011-12-29 21:53:30

+0

听起来像您不经意间更改了项目的配置或类路径。 – mharper 2011-12-29 21:56:53

回答

3

一种可能性:你可能已经创建了自己的类c alled Class。那肯定会导致这两个错误。一种检查(不仅仅是试图找到违规类)的方法是将第一行改为:

java.lang.Class ourClass = java.lang.Class.forName(
    "com.example.exampleone" + cheese);