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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 古典概率c30怎么算_概率分为古典概率和什么概率

    古典概率c30怎么算_概率分为古典概率和什么概率》》点赞,收藏+关注,理财&技术不迷路《《目录:3.古典概率ClassicalProbability频率概率:古典概型:这个例子,n的区别就是指定和没有指定。后面365*364*******意思是每个人的生日都不一样,就是一个排列。题目要求的至少两人,它的对立面就是少于两人,那意思就是每一个人的生日都不一样。4.几何概率geometricprobability面积示例:思考下面这种问题方式,不用从几何导代数,要依靠几..

    2022年10月19日
  • 修改国内yum源

    修改国内yum源

    2021年10月8日
  • jquery获取cookie值的方法_vue获取cookie的值

    jquery获取cookie值的方法_vue获取cookie的值cookie有四个不同的属性: 名称,内容,域,路径 代码如下复制代码$.cookie(‘the_cookie’);//读取cookie $.cookie(‘the_cookie’,’the_value’);//存储cookie $.cookie(‘the_cookie’,’the_value’,{expires:7});

    2022年10月22日
  • 关于淘汰85%查看面试官百度开发者面对的问题

    关于淘汰85%查看面试官百度开发者面对的问题

    2022年1月2日
  • 【题解】递归数列

    【题解】递归数列"题目链接"题目大意:给定序列迭代规则,求一段的序列和。特点是要求的序列很长。Solution观察到,由于是求和,我们可以想到前缀和的思想。也就是说,对于求$\sum_{i=

    2022年7月2日
  • python基础编程100例_菜鸟编程python100例

    python基础编程100例_菜鸟编程python100例推荐下我自己建的人工智能Python学习群:[672948930],群里有我整理的一份关于pytorch、python基础,图像处理opencv\自然语言处理、机器学习、数学基础等资源库,想学习人工智能或者转行到高薪资行业的,大学生都非常实用,无任何套路免费提供!还可以扫码加VX领取资料哦!正文开始:1、题目:列表转换为字典。程序源代码:1#!/usr/bin/envpython2#-*-coding:UTF-8-*-34i=[‘a’,’b’]5l..

    2022年11月1日

发表回复

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

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