当前位置:经典范文谷>简历资料>面试试题>

java常见面试题

面试试题 阅读(2.36W)

用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();
}
}