class FindElement
{
public static void main(String[] args)
{
getIndex(-1);
char ch=getIndex(-1);
System.out.println(ch);
}
public static char getIndex(int index)
{
if(index<0)
{
System.out.print("你输入的下标不存在");
return ' ';
}
char [] arr={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E'};
return arr[index];
}
}
为什么输入正数打印一次,输入负数打印两次你输入的下标不存在? |
|