标签:
java中,声明类使用new关键字
类名 类变量名 = new 类名(构造函数形参表);
静态函数内不能有非静态类,但是可以有非静态函数。
package com.company; /** * Created by hurle on 2016/4/23. */ import java.util.Arrays; public class Array { public static void printA(){ System.out.println("Print A"); } public static void printB(){ System.out.println("Print B"); } public static class printAC{ public void printA(){ System.out.println("Print Class A"); } } public static class printBC{ public void printB(){ System.out.println("Print Class B"); } } public static void main(String args[]){ printA(); printB(); printAC AC=new printAC(); printBC BC=new printBC(); AC.printA(); BC.printB(); } }
输出结果
Print A
Print B
Print Class A
Print Class B
Process finished with exit code 0
标签:
原文地址:http://www.cnblogs.com/liutianchen/p/5544359.html