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>

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

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

(0)
上一篇 2022年7月7日 下午2:16
下一篇 2022年7月7日 下午2:16


相关推荐

  • HttpClient详细解释

    HttpClient详细解释Http协议的重要性相信不用我多说了,HttpClient相比传统JDK自带的URLConnection,增加了易用性和灵活性(具体区别,日后我们再讨论),它不仅是客户端发送Http请求变得容易,而且也方便了开发人员测试接口(基于Http协议的),即提高了开发的效率,也方便提高代码的健壮性。因此熟练掌握HttpClient是很重要的必修内容,掌握HttpClient后,相信对于Http协议的了解会

    2025年6月1日
    6
  • maven打包命令—P,指定springboot项目的配置文件「建议收藏」

    maven打包命令—P,指定springboot项目的配置文件「建议收藏」适用于jekins配置打包环境。线下我们使用的dev环境,线上,测试环境就有不同的配置文件了。只需要在jekins的打包命令加入-Pprod,就可以了。prod对应相应的环境。但是还需要在maven的配置文件<project>节点里面加入<profiles><!–开发–><profile><!-…

    2022年5月20日
    52
  • JSP与Servlet的区别「建议收藏」

    JSP与Servlet的区别「建议收藏」JSP与Servlet的区别一、最重要的一句话!!jsp就是在html里面写java代码,servlet就是在java里面写html代码…其实jsp经过容器解释之后就是servlet.只是我们自己写代码的时候尽量能让它们各司其职,jsp更注重前端显示,servlet更注重模型和业务逻辑。不要写出万能的jsp或servlet来即可。二、对比1)什么是Servlet?Servlet其实就是一个遵循Servlet开发的java类。Servlet是由服务器调用的,运行在服务器端。2)为什么要用到Serv

    2022年6月18日
    27
  • Go . 内置函数 new 新特性

    Go . 内置函数 new 新特性

    2026年3月12日
    3
  • WPF图表控件

    WPF图表控件在用 WPF 开发中 我们也会涉及到用图表来表示数据 而用图表可以直观表示 让客户一目了然 那么图表在 WPF 中应运而生 而在 WPF 中使用图表控件来实现这一效果 其中图表控件也有很多 比如 柱形图 Column 曲线图 Line 折线图 StepLine 饼图 Pie 横道图 Bar 等等 相关步骤 首先创建 WPF 项目 并且引用 WPFVisifire Charts dll 引用 xmlns chart clr namespace Visifire Charts assembly WPFVisi

    2026年3月18日
    2
  • Fisher Information学习笔记

    Fisher Information学习笔记FisherInfomation的意义FisherInformation顾名思义,就是用来衡量样本数据的信息量的,通常我们有一组样本,我们在机器学习中需要估计出样本的分布,我们是利用样本所具有的信息量来估计参数的,样本中具有的信息量越多,估计的参数越准,样本的分布估计的就越接近真实分布,这里的信息量就是用FisherInformation来表示的。什么样本信息量比较大?我们用样本发生的概率来

    2026年1月15日
    5

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

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