日期:2014-05-20  浏览次数:20675 次

返回语句不是有吗
public   Object   get(int   index){
    //throws   listIndexOutOfBoundsException;

if(index> =1&&index <=numbers){
Linkone   curr=find(index);
Object   dataitem=curr.getitem();
return   dataitem;
}//end   if
else{
//throw   new   ListOutOfBoundsExcepton( "List   index   out   of   bounds   on   get ");
}//end   else

怎么提示缺少呢

public   Linkone   insertion     (Linkone   headnode,java.lang.Comparable   newitem)
{if((headnode==null)||
(newitem.compareTO(headnode.getitem()) <0)){。。。。。
D:\java\java2\Linkone.java:150:   找不到符号
符号:   方法   compareTO(java.lang.Object)
位置:   接口   java.lang.Comparable
(newitem.compareTO(headnode.getitem()) <0)){
怎么提示找不到符号呢

------解决方案--------------------
把else里面的throw语句注释去掉吧。第二个里面compareTO方法应该是compareTo吧,下次发把代码格式下吧。
------解决方案--------------------
改成
public Object get(int index)throws ListOutOfBoundsExcepton{ //这句改了

if(index> =1&&index <=numbers){
Linkone curr=find(index);
Object dataitem=curr.getitem();
return dataitem;
}//end if
else{
throw new ListOutOfBoundsExcepton( "List index out of bounds on get ");//这句去掉注释
}//end else
------解决方案--------------------
java语言检查程序的所有分支是否都有返回语句可以返回值
比如
if()
{
return 9;
}
else
{
// no return
}
在else分支上没有返回语句,这样程序就不能保证一定能返回一个值。