非静态内部类: 特点: 内部类不能够使用静态成员 内部类能够访问外部类的所有属性 继续看例子: package self.study.test; public class Outer { int i=100; int j=200; static int a=300; void sayhello(){ Inner inner=new Inner(); //需要实例化 System.out.println(inner.m+inner.n); } class Inner{ int m=1; int n=2; //static int b=12; //error void f1(){ System.out.println(i+j); System.o...
by studyj - Java文档中心 - 2007-06-23 16:30:11 阅读(400) 回复(0)
内部类的使用: 什么是内部类:定义在一个类内部的类 比如 A内部定义了B那么 B就是A的内部类 内部类的分类: 静态内部类: 特点: 1 内部类前面需要添加static 标识符 可以访问外部类的静态变量 但是不能够访问外部类的非静态成员,在访问外部类的成员的时候需要使用 对象类进行访问 举例:package self.study.test; public class Outer { static int i=100; int j=200; static class Inner{ int k=100; static i...
static class declarations Can a class -- inner or outer -- be declared static? By Java Q&a Experts, JavaWorld.com, 08/20/99 Can a class (whether an inner or outer class) be declared static? In order to understand the use of the static keyword in class declaration, we need to understand the class declaration itself. You can declare two kinds of classes: top-level classes and inner classes. Top-l...
hi, 这个是我在国外的论坛上发的帖子,但是想起这里也是有很多国内的牛人,所以发到这里来请求帮助 i have trouble to define a static member in a template, and i search from google, but didn't find any similar case, my case is a little complex, i paste the code below. code in xxx.h [code]template <class T> class FreeListManager { public: FreeListManager(int s=0); ~FreeListManager(); T* acquire...
Python provides a feasible way to define static method in class called staticmethod, just as following code: class MyClass: @staticmethod def Hello(name): print "Hello, %s" % (name) The "@staticmethod" form is a function decorator used to denote the function Hello will act as a static method for class MyClass. Now you can call the method Hello with two ways, MyClass.Hello("...
前言: 本来是想总结一下inner class 的用法,但是却发现这几位颇为亲近。索性一起拉出来溜溜。 写作目的: 跟 static , final, inner class 搞好关系,以便将来遇见了,就像用if ,else一样,一清二楚。 文中的术语定义以java language spec为准。 先想想,要关注的是那些地方? 1。语法。 (code, 我们吃饭的家伙) 2。语义。 (其实写代码也就是为了这个) 3。怎么用简单,可人的结构来表达语义。(这也是每个程序员追求...
看别人写的代码,看到有这样一条代码: static class class$java$util$Hashtable; 不知何解??????? 请各位帮我解释一下!!!!!!!!
[code]class AA { public: ... struct BB{ int a = 0; float b; } privated; BB bb; } [/code] 着重部分那一句,不能这样做,编译器报错(GCC3。2。2) 那我怎样对它做初始化呢?
static int palisade_start P((int, struct peer *)); 我觉得效果应该是static int palisade_start(int,struct peer*); 怎么实现的上述声明? [ 本帖最后由 cattiger 于 2006-12-8 17:19 编辑 ]