黑马程序员技术交流社区
标题:
下面代码,哪个地方有错呢?
[打印本页]
作者:
官珺伟
时间:
2014-1-3 14:58
标题:
下面代码,哪个地方有错呢?
本帖最后由 官珺伟 于 2014-1-3 15:17 编辑
class Count
{
public static int counter;
static
{
counter=123;
System.out.println("Now in static block.");
}
public void test
{
System.out.println("test method=="+counter);
}
}
public class Test
{
public static void main(String args[])
{
System.out.println("counter="+Count.counter);
new Count().test();
}
}
//运行结果是:
//Now in static block.counter=123
//test method==123
复制代码
作者:
王清
时间:
2014-1-3 15:06
text()
作者:
几番意难相付
时间:
2014-1-3 15:08
第九行test方法后面少了一对括号
作者:
taoge
时间:
2014-1-3 15:14
class Count
{
public static int counter;
static
{
counter=123;
System.out.println("Now in static block.");
}
public void test() //这里少了()
{
System.out.println("test method=="+counter);
}
}
public class Test
{
public static void main(String args[])
{
System.out.println("counter="+Count.counter);
new Count().test();
}
}
//运行结果是:
//Now in static block.
//counter=123
//test method==123
复制代码
作者:
黑马IT学员
时间:
2014-1-3 15:35
对,就是缺少了一个括号,亲!不要犯低级错误
作者:
董月峰
时间:
2014-1-3 17:05
public void test()
第九行test方法后面少了一对括号
作者:
晏勇
时间:
2014-1-4 08:52
第九行test少了个(),建议楼主学习了一段java后用myeclipase做开发,如果你少写了个括号或标点符号它会提示错误。
作者:
净坛使者
时间:
2014-1-4 09:10
亲text()少括号了
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/)
黑马程序员IT技术论坛 X3.2