码迷,mamicode.com
首页 > 其他好文 > 详细

内部类的使用

时间:2018-07-19 20:59:42      阅读:144      评论:0      收藏:0      [点我收藏+]

标签:static   todo   getname   org   com   play   package   this   str   

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();
}
}

内部类的使用

标签:static   todo   getname   org   com   play   package   this   str   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!