关于变量定义类型的问题
我把变量定义了INT型,为什么还是出错?
import java.awt.*;
import java.applet.*;
public class Biao extends Applet {
public void paint(Graphics g) {
int num1,num2,num3,yPos=40;
g.drawString("N", 25, 25 );
g.drawString("10*N", 75, 25 );
g.drawString("100*N", 125, 25 );
g.drawString("1000*N", 175, 25 );
for(int n=1;n<=5;n++){
num1=n*Math.pow(10,n);
num2=n*Math.pow(10,n+1);
num3=n*Math.pow(10,n+2);
g.drawString(Integer.toString(n),25, yPos );
g.drawString(Integer.toString(num1), 75, yPos );
g.drawString(Integer.toString(num2), 125, yPos );
g.drawString(Integer.toString(num3), 175, yPos );
yPos+=20;
}
}
}
biao.java:28: possible loss of precision
found : double
required: int
num1=n*Math.pow(10,n);
^
biao.java:29: possible loss of precision
found : double
required: int
num2=n*Math.pow(10,n+1);
^
biao.java:30: possible loss of precision
found : double
required: int
num3=n*Math.pow(10,n+2);
^
3 errors