java找不着符号_找不到符号:Java

java找不着符号_找不到符号:Java如果这是一个怪异的问题,我感到很抱歉,但是我刚刚开始OOP,并遇到了一个我应该制作的简单菜单驱动数学程序。我清除了编译器给我的所有错误,但是现在它给了我大约14个新错误,其中大多数被描述为“找不到符号”。这是我的代码:importjava.util.Scanner;publicclassMathMenu{//MENUMETHODprivatestaticvoidmenu(String…

大家好,又见面了,我是你们的朋友全栈君。

如果这是一个怪异的问题,我感到很抱歉,但是我刚刚开始OOP,并遇到了一个我应该制作的简单菜单驱动数学程序。我清除了编译器给我的所有错误,但是现在它给了我大约14个新错误,其中大多数被描述为“找不到符号”。这是我的代码:

import java.util.Scanner;

public class MathMenu

{

//MENU METHOD

private static void menu(String args[])

{

int choice;

System.out.printf(“Enter ‘1’ to add”);

System.out.printf(“Enter ‘2’ to subtract”);

System.out.printf(“Enter ‘3’ to exit”);

System.out.printf(“\nPlease enter your choice: “);

choice=input.nextInt();

if (choice==1)

sum(n,m);

if (choice==2)

dif(n,m);

else if(choice==3)

return;

}

//SUM

private static int sum(int a, int b)

{

return n+m;

}

//DIFFERENCE

private static int dif(int a, int b)

{

if(n

return m-n;

else

return n-m;

}

public static void main(String args[])

{

int n=15;

int m=8;

Scanner input = new Scanner(System.in);

menu();

}

}

这是新的编译器输出:

Microsoft Windows [Version 6.1.7601]

Copyright (c) 2009 Microsoft Corporation. All rights reserved.

C:\Users\Shahraiz Tabassam>cd c:\java\bin

c:\java\bin>javac MathMenu.java

MathMenu.java:7: error: no suitable constructor found for Scanner()

private static Scanner input = new Scanner();

^

constructor Scanner.Scanner(ReadableByteChannel,String) is not applicable

(actual and formal argument lists differ in length)

constructor Scanner.Scanner(ReadableByteChannel) is not applicable

(actual and formal argument lists differ in length)

constructor Scanner.Scanner(String) is not applicable

(actual and formal argument lists differ in length)

constructor Scanner.Scanner(Path,Charset) is not applicable

(actual and formal argument lists differ in length)

constructor Scanner.Scanner(Path,String) is not applicable

(actual and formal argument lists differ in length)

constructor Scanner.Scanner(Path) is not applicable

(actual and formal argument lists differ in length)

constructor Scanner.Scanner(File,CharsetDecoder) is not applicable

(actual and formal argument lists differ in length)

constructor Scanner.Scanner(File,String) is not applicable

(actual and formal argument lists differ in length)

constructor Scanner.Scanner(File) is not applicable

(actual and formal argument lists differ in length)

constructor Scanner.Scanner(InputStream,String) is not applicable

(actual and formal argument lists differ in length)

constructor Scanner.Scanner(InputStream) is not applicable

(actual and formal argument lists differ in length)

constructor Scanner.Scanner(Readable) is not applicable

(actual and formal argument lists differ in length)

constructor Scanner.Scanner(Readable,Pattern) is not applicable

(actual and formal argument lists differ in length)

MathMenu.java:64: error: method menu in class MathMenu cannot be applied to give

n types;

menu();

^

required: String[]

found: no arguments

reason: actual and formal argument lists differ in length

2 errors

c:\java\bin>

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/156306.html原文链接:https://javaforall.cn

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(0)


相关推荐

发表回复

您的电子邮箱地址不会被公开。

关注全栈程序员社区公众号