易截截图软件、单文件、免安装、纯绿色、仅160KB

Inner classes in Java, the mystery within.

Inner classes, also called Nested Classes, are nothing but classes that are defined within other classes. The nesting is a relationship between classes, not objects.
Inner classes have clearly two benefits, name control & access control. In Java, this benefit is not as important because Java packages give the name control.
Java inner classes have feature that makes them richer and more useful. An object of an inner class has an implicit reference to the outer class object that instantiated it. Through this pointer, it gains access to any variable of the outer object. Only static inner classes don’t have this pointer. It is actually invisible when we write the code, but compiler takes care of it. Inner classes are actually a phenomenon of the compiler and not the JVM.
Inner classes may be defined with following access modifiers : public, protected, private, or with default package access.
The syntax for inner class is as follows:
[modifiers] class OuterClassName {
code...
[modifiers] class InnerClassName {
code....
}
}
Inner Classes:
Following properties can be noted about Inner classes:
The outer class (the class containing the inner class) can instantiate as many number of inner class objects as it wishes, inside it’s code.
If the inner class is public & the containing class as well, then code in some other unrelated class can as well create an instance of the inner class.
In above case the inner class can be created as follows:
<OuterClassName> outerObj = new <OuterClassName>(arguments);
outerObj.<InnerClassName> innerObj = outerObj.new <InnerClassName>(arguments);
No inner class objects are automatically instantiated with an outer class object.
If the inner class is static, then static inner class can be instantiated without an outer class instance, otherwise, the inner class object must be associated with an instance of the outer class.
Inner class code has free access to


相关文档:

Java中 ArrayList、Vector和LinkedList 的使用


/*
ArrayList是最常用的List实现类,内不是通过数组实现的,它允许对元素进行快速随机访问。数组的缺点是每个元素之间不能含有“空隙”,当数组大小不满足时需要增加存储能力,就要将已有数组数据复制到新的存储空间中。当从ArrayList的中间位置插入或者删除元素时,需要对数组进行复制、移动,代价比较高。因 ......

java 保留2位小数

java  保留2位小数  转载
方式一:
四舍五入
double   f   =   111231.5585;
BigDecimal   b   =   new   BigDecimal(f);
double   f1   =   b.setScale(2,   BigDecimal.ROUND_HALF_UP). ......

JTAPI Java Telephony API

接触了JTAPI开发一段时间,刚开始接触时,非常头大,很多概念不好理解。 先列个框架,记录一下自己的学习过程。
一、JTAPI (Java Telephony API )
    在JTAPI之前,每个公司都是各自的一套CTI开发接口。为了统一业界标准,SUN公司推出了jtapi标准接口。该接口定义了呼叫中心中的很多对象,如Address,Agen ......

java环境变量配置及第一个java程序

来CSDN也有一年时间了,一直没有在自己的空间里发表一点东西。
前几天,我朋友想和我一起搞个东西,需要用到java,我没有一点java基础。没办法,只能够从头开始了学习。
从图书馆抱回了两本书《java2入门 进阶与应用实例》和《java me 实用详解》。由于有C和C++的基础,初略看了一下书,对于书中的内容基本上还是能够理解 ......

java四舍五入BigDecimal

java四舍五入
package Test;
import java.math.BigDecimal; //引入这个包
public class Test {
  public static void main(String[] args) {
   double i = 3.856;
   // 舍掉小数取整
   System.out.println("舍掉小数取整:Math.floor(3.856)=" + (int) Math.floor(i));
......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号