关于J2ME数组的复制及连接操作方法
public class Arrays {
/**
* 构造函数私有,这样可以保证只能通过:类名.静态方法 或 类名.静态方法 来访问内部数据,
* 而不可以通过创建本类的对象来进行访问
*/
private Arrays() {
}
/**
* 复制一个跟源byte数组一样的byte数组
* @param rSource 源byte数组
* @return 跟源byte[]数组一样的byte[]数组
*/
static public byte[] copy(byte[] rSource) {
byte[] aResult = new byte[th];
ycopy(rSource, 0, aResult, 0, th);
return aResult;
}
/**
* 复制一个跟源int数组一样的int数组
* @param rSource 源int数组
* @return 跟源int数组一样的数组
*/
static public int[] copy(int[] rSource) {
int[] aResult = new int[th];
ycopy(rSource, 0, aResult, 0, th);
return aResult;
}
/**
* 比较两个byte数组的内容及长度是否相等.
* @param a1 第一个byte数组
* @param a2 第二个byte数组
* @return 相等的话返回true,否则返回false
*/
static public boolean equals(byte[] a1, byte[] a2) {
if ( (a1 == null) || (a2 == null)) {
return a1 == a2;
}
int nLength = th;
if (nLength != th) {
return false;
}
for (int i = 0; i < nLength; i++) {
if (a1[i] != a2[i]) {
return false;
}
}
return true;
}
/**
* 比较两个int数组的内容及长度是否相等.
* @param a1 第一个int数组
* @param a2 第二个int数组
* @return 相等的话返回true,否则返回false
*/
static public boolean equals(int[] a1, int[] a2) {
if ( (a1 == null) || (a2 == null)) {
return a1 == a2;
}
int nLength = th;
if (nLength != th) {
return false;
}
for (int i = 0; i < nLength; i++) {
if (a1[i] != a2[i]) {
return false;
}
}
return true;
}
/**
* 连接两个byte数组,之后返回一个新的连接好的byte数组
* @param a1
* @param a2
* @return 一个新的连接好的byte数组
*/
static public byte[] join(byte[] a1, byte[] a2) {
byte[] result = new byte[th + th];
ycopy(a1, 0, result, 0, th);
ycopy(a2, 0, result, th, th);
return result;
}
/**
* 连接两个int数组,之后返回一个新的连接好的int数组
* @param a1
* @param a2
* @return 一个新的连接好的int数组
*/
static public int[] join(int[] a1, int[] a2) {
int[] result = new int[th + th];
ycopy(a1, 0, result, 0, th);
ycopy(a2, 0, result, th, th);
return result;
}
}
-
Sun推出的Java认证指南
sun公司名称的由来很多人不知道,它其实是斯坦福大学校园网(StanfordUniversityNetwork)的首字母缩写。下面是小编整理的Sun推出的Java认证指南,欢迎大家参考!Sun推出的专业认证包括下列三种:◆JAVA认证考试对于JAVA程序设计员,Sun推出两项认证:SunCertifiedJAVAPro...
-
初级java程序员面试试题
程序员(英文Programmer)是从事程序开发、维护的专业人员。一般将程序员分为程序设计人员和程序编码员,但两者的界限并不非常清楚,特别是在中国。下面是小编整理的关于初级java程序员面试试题,希望大家认真阅读!1.学习方向与面试简历的相关问题1.如何过简历关?我先...
-
Java学习要点汇总
Sun公司对Java编程语言的解释是:Java编程语言是个简单、面向对象、分布式、解释性、健壮、安全与系统无关、可移植、高性能、多线程和动态的语言。下面小编准备了关于Java的学习要点,提供给大家参考!1.你需要精通面向对象分析与设计(OOA/OOD)、涉及模式(GOF,J2EED...
-
Java日志系统框架的设计与实现
在Java领域,存在大量的日志组件,open-open收录了21个日志组件。日志系统作为一种应用程序服务,对于跟踪调试、程序状态记录、崩溃数据恢复都有着重要的作用,我们可以把Java日志系统看作是必不可少的跟踪调试工具。1.简介日志系统是一种不可或缺的跟踪调试工具,特别...