没有任何类型 Test1 的外层实例可访问。必须用类型 Test1 的外层实例(例如,x.new A(),其中 x 是 Test1 的实例)来限定分配。
来源:互联网 发布:九十年代流行网络歌曲 编辑:程序博客网 时间:2024/06/06 05:21
在main方法中创建类Person,视为内部类,可以直接new Person,在main方法外创建的类,需要先实例化一个外层的对象A,再通过A.new来实例类Person
package new_start1;public class Test1 {class Person{public String name;public int age;public Person(String n,int g){this.name=n;this.age=g;}}public static void change(Person a){a.name="haha";}public static void main(String[] args) {//直接new会报错,Person p=new Person("zhangsan",12); Test1 t=new Test1();//创建一个外部实例 Person p=t.new Person("xxx",1);//通过外部实例t实例化Person }}
0 0
- 没有任何类型 Test1 的外层实例可访问。必须用类型 Test1 的外层实例(例如,x.new A(),其中 x 是 Test1 的实例)来限定分配。
- 内部类问题--java编程中没有任何类型 abc 的外层实例可访问问题
- 数组的使用Test1
- test1
- test1
- test1
- test1
- test1
- test1
- TEST1
- test1
- test1
- TEST1
- Test1
- test1
- Test1
- Test1
- Test1
- ZOJ 1068 P,MTHBGWB
- IO流找不到电脑磁盘文件中的路径
- 一.javaweb笔记之javaScript简介+基本语法+事件驱动+DOM
- 二.javaweb笔记之JQuery学习路线+语法+常用选择器
- Github全面详解-06创建代码仓库
- 没有任何类型 Test1 的外层实例可访问。必须用类型 Test1 的外层实例(例如,x.new A(),其中 x 是 Test1 的实例)来限定分配。
- The reference to entity "characterEncoding" must end with the ';' delimiter
- 三.javaweb笔记之xml解析
- 四.javaweb之web环境的搭建
- [组合数取模] BZOJ 4830 [Hnoi2017]抛硬币
- The prefix "tx" for element "tx:annotation-driven " is not bound The prefix "tx" for element "tx:ann
- 记CentOs服务器内存使用满的解决办法
- 五.javaweb之Http协议
- IMWeb训练营作业----todo list