【发布时间】:2013-08-01 05:59:27
【问题描述】:
我是编程新手,我想知道我在实例化对象时哪里出错了。下面是代码:
public class Testing{
private int Sample(int c)
{
int a = 1;
int b = 2;
c = a + b;
return c;
}
public static void main(String []args)
{
Sample myTest = new Sample();
System.out.println(c);
}
}
【问题讨论】:
-
变量
c可以在Sample方法的范围内访问。你试图在这个范围之外访问它。
标签: java instantiation