`
renhongchao
  • 浏览: 120931 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

No enclosing instance of type CheckInMethods is accessible

    博客分类:
  • java
 
阅读更多
非静态内部类必须在外部类的非静态成员里构造  我是写main里面了所以报错了
也可以用.new在main创建内部类 代码如下


public class InnerClass {
	
	public InnerClass() {
	}
	
	class Inner{
		public Inner() {
			System.out.println("inner class");
			//.this指向外部类对象
			System.out.println(Inner.this);
		}
	}
	
	public Inner asdf(){
		InnerClass.Inner inner = new Inner();
		return inner;
	}

	public static void main(String [] args){
		InnerClass insd = new InnerClass();
		insd.asdf();
		//.new创建内部类对象
		insd.new Inner();
 	
	}
}
分享到:
评论

相关推荐

    Java解决No enclosing instance of type PrintListFromTailToHead is accessible问题的两种方案

    Java编程语言中的"No enclosing instance of type"错误通常发生在尝试创建非静态内部类的实例,但没有一个外部类的实例可以访问时。在上述示例中,`ListNode`是`PrintListFromTailToHead`类的非静态内部类。由于`...

    java编译中存在的问题及原因分析

    在Java中,当你尝试在静态上下文中创建非静态内部类的对象时,会遇到以下错误信息:“No enclosing instance of type EmployeeTest is accessible. Must qualify the allocation with an enclosing instance of type...

    2009 达内Unix学习笔记

    集合了 所有的 Unix命令大全 ...telnet 192.168.0.23 自己帐号 sd08077-you0 ftp工具 192.168.0.202 tools-toolss ... 各个 shell 可互相切换 ksh:$ sh:$ csh:guangzhou% bash:bash-3.00$ ... 命令和参数之间必需用空格隔...

    Google C++ Style Guide(Google C++编程规范)高清PDF

    The goal of this guide is to manage this complexity by describing in detail the dos and don'ts of writing C++ code. These rules exist to keep the code base manageable while still allowing coders to ...

    Borland Delphi 2005 Architect Update 3

    F2084 Internal Error SCR765.00 of 5 Closed11193 Inlined function affects working of the enclosing for loop0.00 of 5 Closed11184 [Fatal Error] F2084 Internal Error: ILLK26340.00 of 5 Closed11069 ...

    Secrets of the JavaScript Ninja, 2nd Edition

    Generators are a special type of function that can pause and resume execution, allowing the generation of values on demand. They use the `yield` keyword to produce a sequence of values. For instance: ...

    Eclipse Template与模式

    private static final ${enclosing_type} m_instance = new ${enclosing_type}(); /** * 私有的默认构造子 */ private ${enclosing_type}() {} /** * 静态工厂方法 */ public static ${enclosing_type}...

    embedded system design

    This importance of embedded systems is so far not well reflected inmany of the current curricula. This book is intended as an aid for changing this situation. It provides the material for a first ...

    Android 中LayoutInflater.inflate()方法的介绍

    Android 中LayoutInflater.inflate()方法的介绍 Android 中LayoutInflater.inflate()方法是Android开发中最常用的方法之一,用于将布局文件转换成View对象。该方法是LayoutInflater类中的一个成员方法,主要用于将...

    Mask 98 for PRwin98

    is just a sample of the Windows 95/98 type enhancements Calmira provides to the Windows 3.1 user interface... Taskbar with versatile Start Menu, nested to any level Wastepaper bin to store deleted ...

    max200技术手册

    数控等离子切割技术资料The user is responsible for installing and using the plasma equipment according to the manufacturer’s instructions. If electromagnetic disturbances are detected then it shall be...

    Shell Script

    For instance, if you want to print today's date in a sentence, you would use `$ echo "Today is `date`"`. Here, `date` inside backticks is executed first to get the current date, which is then printed...

    Fractions to Decimals

    If the decimal representation has a repeating sequence of digits, indicate the sequence by enclosing it in brackets. For example, 1/3 = .33333333...is denoted as 0.(3), and 41/333 = 0.123123123...is ...

    Using LUA with Visual C++ (Introduction)

    The first parameter is the pointer to the LUA state, the second parameter is the number of arguments on the stack that the command takes (and when executing a loaded script this can remain 0)....

    Eclipse快捷键大全(

    编辑 Select Enclosing Element Alt+Shift+向上键 Editing in Structured Text Editors 编辑 选择外层元素 Alt+Shift+向上键 编辑 Java 源代码 编辑 Restore Last Selection Alt+Shift+向下键 Editing in Structured...

    成人高等教育国际商务英语复习题及答案.docx

    1. 题目中的选项涉及动词搭配,正确答案是D.enclosing,表示随信附上。这反映了商务信函中常见的表达方式。 2. 产品类别(categories)是市场营销中的术语,指公司生产的产品种类或分类,了解产品类别有助于制定...

    SCJP6 Sun Certificated Programmer for Java 6 Study Guide (Exam 310-065) 英文原版

    Inner classes can access private members of the enclosing class: - **Member Inner Classes**: Declared inside a class but outside any method. - **Local Inner Classes**: Declared inside a method. - **...

    中考英语作文模板和作文病句、错句修改.pdf

    What is more, the advancement in technology has made online education accessible to a broader audience." - 进一步阐述:添加第三点原因,如"Thirdly, the cost-effectiveness of e-learning compared to ...

Global site tag (gtag.js) - Google Analytics