首页 > 其他 > 详细

内部类的使用

时间:2018-07-19 20:49:16      阅读:224      评论:0      收藏:0      [点我收藏+]

package com.gxnu.edu.lqm.collection;

public class NestEx {
private String name;

public class Nest{
public void Nest(String str){
System.out.println(str);
}
}

public static class StaticNest{
public void play(){
System.out.println("play");
}
}

public NestEx() {
super();
// TODO Auto-generated constructor stub
}

public NestEx(String name) {
super();
this.name = name;
}

@Override
public String toString() {
return "NestEx [name=" + name + "]";
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

}

 

 

 

package com.gxnu.edu.lqm.collection.test;

import org.junit.Test;

import com.gxnu.edu.lqm.collection.NestEx;
import com.gxnu.edu.lqm.collection.NestEx.Nest;
import com.gxnu.edu.lqm.collection.NestEx.StaticNest;

public class NestTest {
@Test
public void testNest(){
NestEx nestEx = new NestEx();
NestEx.Nest nest = nestEx.new Nest();
nest.Nest("xxioa");
NestEx.StaticNest staticNest = new NestEx.StaticNest();
staticNest.play();
}

@Test
public void testNest1(){
NestEx nestEx = new NestEx();
Nest nest = nestEx.new Nest();
nest.Nest("xxioa");
StaticNest staticNest = new NestEx.StaticNest();
staticNest.play();
}
}

内部类的使用

原文:https://www.cnblogs.com/jiminluo/p/9337844.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!