小编McD*_*ger的帖子

可能有损转换从double到int并且找不到符号

我的程序中出现错误:

Lyrics.java:11:错误:找不到符号

 Cube(b);
 ^
Run Code Online (Sandbox Code Playgroud)

符号:方法Cube(int)

location:class歌词

Lyrics.java:15:错误:不兼容的类型:从double到int的可能有损转换

 return Math.pow (b, 3);
                   ^
Run Code Online (Sandbox Code Playgroud)

2个错误

我在网站上四处看看,结果发现其他人也有这个问题,但我看了评论,我仍然不明白这个问题,我的代码中没有双重为什么会这样说.而且我也没有找不到错误,说找不到符号.请帮助我真的被困在这一段时间了.

  import static java.lang.Math.pow;
  import java.util.Scanner;

  public class Lyrics
  {
       public static void main(String []args)
       {
            int b;
            Scanner scan = new Scanner(System.in);
            System.out.println ("Enter a number: ");
            b = scan.nextInt();
            Cube(b);
       }
       public static int cube (int b)
       {
            return Math.pow (b, 3);
       }
}
Run Code Online (Sandbox Code Playgroud)

java double int

1
推荐指数
1
解决办法
4万
查看次数

标签 统计

double ×1

int ×1

java ×1