关于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;
}
}
-
SUNJava程序员认证考试题库
Sun认证Java程序员考试旨在观察您通过应用软件分配进行复杂编程的能力,之后还要测试您完成编程所需的知识。以下是小编整理的关于SUNJava程序员认证考试题库,希望大家认真阅读!1.下列哪项不是JDK所包含的内容?(选一项)编程语言B.工具及工具的APIEE扩展API平台虚...
-
Sun国际认证 中国注册 在京正式启动
北京时间3月3日,Sun公司中国培训部在北京金域万豪酒店隆重举办Sun国际认证中国注册启动仪式,这标志着Sun国际认证获得中国官方权威认可,并逐步纳入国家职业技能认证体系的开始。更为有幸的是,中国劳动和社会保障部职业技能鉴定中心鉴定总监李京申也应邀出席了此次...
-
sun java认证考试介绍
在当今信息高速发展的社会中,人才决定了企业发展。因此,如何评估员工的价值,或是个人如何证明自己的专业能力,就成为关键。Sun公司为了为业界建立一套认证的标准,特别针对最先进的科技,推出Java及Solaris技术认证方案。根据这些认证,在企业方面可以藉此作为招聘人才的...
-
sun认证考试:java子对象创建过程
Java创建子类对象的过程:publicclassF511{privateintff=100;protectedintm=880;F511(){m=add(8);}intadd(inti){returni+m;}publicstaticvoidmain(Stringargs[]){F511f=newF511();tln("f="+f.m);S511s=newS511();tln("s="+s.m+"t="+s.t);}}classS511extendsF511...