No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing instanc
来源:互联网 发布:mac创建win7安装u盘 编辑:程序博客网 时间:2024/05/22 02:06
public class TestPerson {
public static void main(String[] args){
Person person = new Person();//这样的话就要遇到错误,,在Java中,类中的静态方法不能直接调用动态方法。只有将某个内部类修饰为静态类,然后才能够在静态类中调用该类的成员变量与成员方法。所以解决办法是将public class改为public static class.
内部可以调用静态的属性或静态的方法,而不能调用非静态的属性或方法,反之,非静态的方法是可以调用静态的属性或静态的方法
}
}
class Person{
//1.属性
String name ;
int age;
boolean sex;
//2.方法
public void eat(){
System.out.println("吃饭");
}
public void sleep(){
System.out.println("碎觉");
}
public String getName(){
return name;
}
//给属性赋值
public void setName(String s){
name = s;
}
public void info(){
System.out.println("name:"+name+"age:"+age+"sex:"+sex);
}
}
=======================================================
package sxt.study.focus;
public class TestPerson {
public static void main(String[] args){
Person person = new Person();
}
class Person{
//1.属性
String name ;
int age;
boolean sex;
//2.方法
public void eat(){
System.out.println("吃饭");
}
public void sleep(){
System.out.println("碎觉");
}
public String getName(){
return name;
}
//给属性赋值
public void setName(String s){
name = s;
}
public void info(){
System.out.println("name:"+name+"age:"+age+"sex:"+sex);
}
}
}//注意这里的括号
- No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing instanc
- No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing instanc
- No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing instanc
- No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing instanc
- No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing instanc
- No enclosing instance of type X is accessible. Must qualify the allocation with an enclosing instanc
- No enclosing instance of type * is accessible. Must qualify the allocation with an enclosing instanc
- No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing
- No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing
- No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing
- No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing insta
- No enclosing instance of type E is accessible. Must qualify the allocation with an en
- [Error]No enclosing instance of type XX is accessible. Must qualify the allocation with an e
- - No enclosing instance of type Test is accessible. Must qualify the allocation with an enclosing in
- No enclosing instance of type Monster is accessible. Must qualify the allocation with an enclosing i
- No enclosing instance of type ChuangKou is accessible. Must qualify the allocation with an enclosing
- No enclosing instance of type X is accessible. Must qualify the allocation with an enclosing
- No enclosing instance of type Test is accessible. Must qualify the allocation with an enclosing inst
- WinCE下开发程序常见问题(非常实…
- 小小的太阳
- 快速应用一款新MCU的方法总结
- wince——配置文件
- Windows CE下流驱动的动态加载
- No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing instanc
- 如何把如何给flash 分两个FAT区域
- YUV 与RGB之间的变换
- 2016.09.03 YLOI 结题报告
- WINCE6.0串口调试信息开关
- WINCE下创建多个文件分区
- Eboot 中给nandflash分区实现
- WinCE6.0中应用程序如何直接访问物…
- sync