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中可以通过Runtime.getRuntime().exec(cmd)来执行外部命令,我比较常用的是调用shell脚本来完成某些工作,也可以直接执行一个os 的命令,比较调用imagemagick来完成图片的一些操作,其中需要注意的有两点,1是最好带上命令的完整路径,否则命令可能不会被执行,而且也没有任何报错的信息输出,2特别要注意空格,比如文 ......
接触了JTAPI开发一段时间,刚开始接触时,非常头大,很多概念不好理解。 先列个框架,记录一下自己的学习过程。
一、JTAPI (Java Telephony API )
在JTAPI之前,每个公司都是各自的一套CTI开发接口。为了统一业界标准,SUN公司推出了jtapi标准接口。该接口定义了呼叫中心中的很多对象,如Address,Agen ......
java环境下调用VC++编写的动态链接库文件
一,开发平台:
MyEclipse 6.0,VC++6.0
二,JNI基础知识:
JNI(java native interface),JAVA本地接口调用,目的是为了JAVA可以调用本地程序。
三,交互过程:
1,建立java类。例如,建立一个RSA加密解密的类:
package zkxx.ctais2.client.common;
public class RsaE ......
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 ......
趁着今天还有点精力,将刚刚学会的APPLET写出来。
感觉用记事本编辑程序太吃力,不过现在是处于学习阶段,先把基本的东西掌握了吧。
JAVA APPLET就是用JAVA语言编写的一些小应用程序,它们可以直接嵌入到网页中或者其他特定容器中,并产生特殊的效果。
JAVA APPLET程序不是将main方法作为入口。
第一个APPLET程序:
打 ......