import  java.io.*;
public  class  Class1
{
public  static  void  main (String[]  args)
{
int  x,y;
String  str=" ";
if(args.length < 2)
{
System.out.println("Usage:number1  number2");
System.exit(-1);
}
x=(int) Float.valueOf(args[0]).floatValue( );//在这个位置报强制转化为int.
  y=Integer.parseInt(args[1]);
str=str+x+" 的 "+y+" 次方 = "+(Math.pow(x,y));
System.out.println( str );
}
}

解决方案 »

  1.   

    x是int型,所以需要做一个(int)强制转换。
      

  2.   

    同意!
    在此,属于窄化转换(narrowing conversion),需要使用显式定义。
      

  3.   

    详见转型运算符(Casting Operators)
      

  4.   

    楼上的朋友,什么是 窄化转换(narrowing conversion)
    为何必须使显示转化。莫非还有非窄化转换
      

  5.   

    to:
     danceflash(Wine)他在写文章呢。
      

  6.   

    to  AOM(N++++++++++++++++++)  :
    java 里int 是32 bit float 是64 bit; 从float 强制转到int 当然就是窄化了。这样做可能会丢失数据信息。慎用啊!
      

  7.   

    to Leemaasn(我给大家拜早年啦!新春快乐!!!):
      你们都好强啊 ^_^