java常见面试题

进修社 人气:2.43W

用JAVA实现一种排序,JAVA类实现序列化的方法(二种)? 如在COLLECTION框架中,实现比较要实现什么样的.接口?
答:用插入法进行排序代码如下
package test;
import .*;
class  InsertSort
{
ArrayList al;
public InsertSort(int num,int mod)
{
al = new ArrayList(num);
Random rand = new Random();
tln(”The ArrayList Sort Before:”);
for (int i=0;i<num ;i++ )
{
(new Integer((Int()) % mod + 1));
tln(”al["+i+"]=”+(i));
}
}
public void SortIt()
{
Integer tempInt;
int MaxSize=1;
for(int i=1;i<();i++)
{
tempInt = (Integer)ve(i);
if(alue()>=((Integer)(MaxSize-1))alue())
{
(MaxSize,tempInt);
MaxSize++;
tln(ring());
} else {
for (int j=0;j<MaxSize ;j++ )
{
if

java常见面试题

(((Integer)(j))alue()>=alue())
{
(j,tempInt);
MaxSize++;
tln(ring());
break;
}
}
}
}
tln(”The ArrayList Sort After:”);
for(int i=0;i<();i++)
{
tln(”al["+i+"]=”+(i));
}
}
public static void main(String[] args)
{
InsertSort is = new InsertSort(10,100);
It();
}
}

 

TAGS:Java 面试题