⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 classexample.java

📁 关于java编程的一些练习题。内附习题及源码文件。。。。系列二
💻 JAVA
字号:
//: ClassExample.java

//package g3ds.joop.ch3;

public class ClassExample{
	// 声明成员属性,可以是静态的或非静态的
	int i;
	static int j;
	
	// 静态初始化语句块
	static{
		j=10;
		System.out.println("In static initializer.");
	}
	
	// 实例初始化语句块
	{
		i=10;
		System.out.println("One In instance initializer.");		
	}
	
	// 构造方法
	public ClassExample(){
		System.out.println("In constructor.");		
	}
	
	{
		System.out.println("Two In instance initializer.");
	}
	
	// 内嵌类,可以是静态的或非静态的
	static class NestedClass implements InnerInterface{
		public void f(){
			System.out.println("实现接口的方法f().");
		}
	}
	
	// 内嵌接口,无论显式或隐式声明都是静态的
	interface InnerInterface{void f();}

	// 定义成员方法,可以是静态的或非静态的
	public static void main(String[] args){
		new ClassExample();
		NestedClass nc=new NestedClass();
		nc.f();
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -