不好意思,是这样的:
public class PrivateTest1
{
public static void main(String[] args)
{
PriTest atestnex = new PriTest("Test");
System.out.print(atestnex.fuc());
} class PriTest
{
public PriTest(String test)
{
t=test;
} public String fuc()
{
t = "This is " + t;
return t;
} private String t;
}
}
public class PrivateTest1
{
public static void main(String[] args)
{
PriTest atestnex = new PriTest("Test");
System.out.print(atestnex.fuc());
} class PriTest
{
public PriTest(String test)
{
t=test;
} public String fuc()
{
t = "This is " + t;
return t;
} private String t;
}
}
解决方案 »
- eclipse 中的中文注释全乱码了,求救,紧急。。。。
- 各位大虾麻烦帮我看看为什么我GUI界面无法显示?
- 大家来谈谈setContextClassLoader的真正作用
- FtpClient类问题
- Java编程思想第二版好还是第三版好
- 问:又没有一种文本组件可以显示一个整型的值,但不能编辑,我用它来显示在线用户的数目。
- 如何使用Swing 实现画图功能,需要在什么容器上?
- JB连数据库问题,送你60分
- 子类对象能访问父类对象中的protected域吗?
- 有哪位大神指导下什么情况(或那个部分)下jvm需要重启电脑才会释放缓存
- 用这个程序取random随机值,得到的结果为什么会是0??
- 高人指点几行代码不难,只是我不懂
public class PrivateTest1
{
public static void main(String[] args)
{
PriTest atestnex = new PriTest("Test");
System.out.print(atestnex.fuc());
} class PriTest
{
public PriTest(String test)
{
t=test;
} public String fuc()
{
t = "This is " + t;
return t;
} private String t;
}
}
为什么编译时提示出错:
在静态上下文中不能引用非静态变量 this
PriTest atestnex = new PriTest("Test");
至其enclosing class的某个对象。 因此如果不修改你这个程序的结构,在main()函数中作如下修改
PrivateTest1 a=new PrivateTest1();
PriTest atestnex = a.new PriTest("Test");
System.out.print(atestnex.fuc());
public class EmployeeSortTest1
{
public static void main(String[] args)
{
Employee staff = new Employee("Angel",6666);
System.out.println("Before "+staff.getName()+",salary is "+staff.getSalary());
}
}class Employee
{
public Employee(String n,double s)
{
name = n;
salary = s;
} public String getName()
{
return name;
} public double getSalary()
{
return salary;
} private String name;
private double salary;
}