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 json lib
根据http://www.javaeye.com/topic/561368谈到的一个jackson的json序列化工具性能比json-lib等要好
无论是在低并发还是高并发的情况下,时间性能上,jackson使用重用ObjectMapper方式大大优于使用json-lib方式,甚于jackson使用非重用ObjectMapper方式也略优于json-lib方式。另外也可以看出,jackson在重用 ......
1、java.lang包:java的核心类库,包含了运行java程序必不可少的系统类,如基本数据类型、基本数学函数、字符串处理、线程、异常处理类等,系统缺省加载这个包
2、java.io包:java语言的标准输入/输出类库,如基本输入/输出流、文件输入/输出、过滤输入/输出流等等
3、java.util包:包含如处理时间的date类,处理变成数 ......
接触了JTAPI开发一段时间,刚开始接触时,非常头大,很多概念不好理解。 先列个框架,记录一下自己的学习过程。
一、JTAPI (Java Telephony API )
在JTAPI之前,每个公司都是各自的一套CTI开发接口。为了统一业界标准,SUN公司推出了jtapi标准接口。该接口定义了呼叫中心中的很多对象,如Address,Agen ......
Comparator和Comparable在排序中的应用
当需要排序的集合或数组不是单纯的数字型时,通常可以使用Comparator或Comparable,以简单的方式实现对象排序或自定义排序。
一、Comparator
强行对某个对象collection进行整体排序的比较函数,可以将Comparator传递给Collections.sort或Arrays.sort。
接口方法:
......
Java程序调用存储过程验证用户登录
package com.yzy.jdbc.dao;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import oracle.jdbc.OracleTypes;
public class LoginDao {
public boolean loginValidate(String username, Stri ......