一、数组是什么?
1.基本概念:
Definition:数组就是相同类型元素的线性集合。
Array is a collection of the same data.
An array is object.
对数组的理解:
数组是一个对象,是一个指向数组的引用对象。
2.Syntax
Array Copy
二、为什么要使用数组?
三、数组主要用在哪些地方?数组不能用在哪些地方?
四、怎么样使用数组?如何更好地使用数组?应该选择怎样的数组(Array,ArrayList,LinkedList,Vector)
1.数组的使用:
A.declare
int [] a=new int[3](声明一个数组类型的成员变量,并创建一个数组)
int[] a={};
int a[]={};
int a[][]={}
B.create
Sample:a=new int[3];
int[] a={1,2,3};
Advanced Feature:
a.在堆中分配连续内存空间;
b.对数组元素赋缺省值;
c.在栈中存放a引用类型变量,并指向堆中的数组
Tips:数组创建的过程
创建长度为2的数组,堆中分配空间,给数组元素赋默认值。
C.initialize(初始化)
&n ......
http://java.sun.com/reference/api/
JavaTM Platform Enterprise Edition, v 5.0
http://java.sun.com/javaee/5/docs/api/
1.Hibernate API Documentation (3.2.2.ga)
http://www.hibernate.org/hib_docs/v3/api/
2.Spring Framework API 2.5
http://static.springframework.org/spring/docs/2.5.x/api/index.html
3.Struts 1.3.8 API
http://struts.apache.org/1.3.8/apidocs/index.html
4.Struts 2 Core 2.0.11.1 API
http://struts.apache.org/2.0.11.1/struts2-core/apidocs/index.html
5.ajax4jsf:JSF的Ajax框架
http://www.jboss.org/file-access/default/members/jbossrichfaces/freezone/docs/apidoc_framework/index.html
6.JBoss API
http://docs.jboss.org/jbossas/javadoc/4.0.5/
7.OSGI R4
http://docs.huihoo.com/javadoc/osgi/r4/
8.JBoss Seam
http://docs.jboss.com/seam/2.1.0.A1/api/
9.Seam JSF Controls 2.1.0.A1 API
http://docs.jboss.com/seam/2.1.0.A1/ui/apidocs/
10.ROR
http://docs.huihoo.com/api/ruby-on-rails/
11.Ruby1.8.4
http://docs.huihoo.com/api/ruby/core/1.8.4/
12.Ruby Stdlib ......
java集合类总结
对象的集合
如果程序的对象数量有限,且寿命可知,那么这个程序是相当简单的。
数组
数组与其它容器的区别体现在三个方面:效率,类型识别以及可以持有primitives。数组是Java提供的,能随机存储和访问reference序列的诸多方法中的,最高效的一种。数组是一个简单的线性序列,所有它可以快速的访问其中的元素。但是速度是有代价的;当你创建了一个数组之后,它的容量就固定了,而且在其生命周期里不能改变。也许你会提议先创建一个数组,等到快不够用的时候,再创建一个新的,然后将旧的数组里的reference全部导到新的里面。其实(我们以后会讲的)ArrayList就是这么做的。但是这种灵活性所带来的开销,使得ArrayList的效率比起数组有了明显下降。
Java对数组和容器都做边界检查;如果过了界,它旧会给一个RuntimeException。这种异常表明这个错误是由程序员造成的,这样你就用不着再在程序里面检查了。
还有一些泛型容器类包括List,Set和Map。他们处理对象的时候就好像这些对象都没有自己的具体类型一样。也就是说,容器将它所含的元素都看成是(Java中所有类的根类)Object的。这样你只需要建一种容器,就能把所有类型的对象全都放进去。从这 ......
通过java jna 调用datastage c api 例子如下,这是运行作业的例子
经测试是可行的。
import com.sun.jna.Library;
import com.sun.jna.Structure;
import com.sun.jna.Union;
import com.sun.jna.Native;
/** Simple example of native library declaration and usage. */
public class dsjobc {
public static class time_t extends Structure {
public int value;
public time_t() {}
public time_t(int value) {
this.value = value;
}
}
public static class DSPROJECT extends Structure{
public int dsapiVersionNo;
public int sessionId;
public byte valueMark;
public byte fieldMark;
}
public static class DSJOB extends Structure{
public DSPROJECT hProject; /* Reference to project handle for job */
String serverJobHandle; /* Text of handle to job on server */
String logData; /* Cached log summary data */
int logDataLen; /* Size of log summary data */
int logDataPsn; /* Current position in logData */
}
public ......
Java中对文件的操作
java中提供了io类库,可以轻松的用java实现对文件的各种操作。下面就来说一下如何用java来实现这些操作。
1。新建目录
<%@
page contentType="text/html;charset=gb2312"%>
<%
String
filePath="c:/aaa/";
filePath=filePath.toString();//中文转换
java.io.File
myFilePath=new
java.io.File(filePath);
if(!myFilePath.exists())
myFilePath.mkdir();
%>
2。新建文件
<%@
page contentType="text/html;charset=gb2312"%>
<%@ page
import="java.io.*" %>
<%
String
filePath="c:/哈哈.txt";
filePath=filePath.toString();
File
myFilePath=new
File(filePath);
if(!myFilePath.exists())
myFilePath.createNewFile();
FileWriter
resultFile=new FileWriter(myFilePath);
PrintWriter myFile=new
PrintWriter(resultFile);
String strContent =
"中文测试".toString();
myFile.println(strContent);
resultFile.close();
%>
3。删除文件
<%@
page contentType="text/html;charset=gb2312"%>
<%
String
filePath="c:/支出证明单.xls";
filePath=fil ......
前言:
工作中经常会接触java,虽然在学校时有C、C++的基础,对简单的java代码还是能应付过去,但是由于缺乏对java深入的学习和理解,在实际使用时仍有无从下手的感觉。前段时间在师兄的推荐下买了java经典教程《Core Java》进行学习,外国人的书写的就是不一样,语言简炼,并附有详细的代码和注释,开始有了入门的感觉,哈哈。为此,决定写下这篇文章,一是作为技术笔记记录下java编译的安装和配置过程,二也可以作为自己学习过程中的回顾和总结。本文记录的是Windows环境下Java编译环境的安装和配置。
正文:
一、安装Java开发工具箱(JDK)
构建Java的编译环境需要安装JDK,可以登录Sun网站下载JDK的可执行安装文件进行安装。我安装的是1.4.2版本的SDK(1.2~1.4版本被称为Java SDK),根据《Core Java》书中所述,windows环境下安装路径名最好不要使用带空格的默认路径名。我使用的路径是“ C:\j2sdk1.4.2 ”
二、环境配置
与VC集成开发环境安装不一样,JDK安装后需自行进行环境的设置。右键单击&ldquo ......