我正在制作一个ATM程序,用cmd来学习java来编译和运行它.该程序编译时没有错误,但在运行时只打印at ATM.(init)(ATM.java:6).
任何帮助将不胜感激!
public class ATM
{
Toolbox myToolbox = new Toolbox();
Integer balance;
ATM myATM = new ATM();
public static void main(String[] arg)
{
ATM myATM = new ATM();
myATM.go();
myATM.printBal();
myATM.mainMenu();
}
public void go()
{
System.out.println("Welcome to online ATM banking");
System.out.println("How much do you want in your account?");
//System.out.println("Enter your number");
balance = myToolbox.readIntegerFromCmd();
}
public void printBal()
{
System.out.println("****************************************");
System.out.println(balance);
System.out.println("****************************************");
}
public void mainMenu()
{
Integer selected;
System.out.println("What do you want to do?"); …Run Code Online (Sandbox Code Playgroud) 我现在有一些这样的例外,我总是在努力解决它们,所以任何有关如何解决它们的指南或建议都会很好,而不必依赖其他人来帮助他们.目前我有一个关于如何解决它的建议将不胜感激,但从长远来看,一般建议如何追查问题的原因会更好.
class Egg extends Bee{
protected void anotherDay() {
eat();
if(age>=3)
{
HashMap<String, Hive> thisHive = Garden.GARDEN.getHiveMap();
Larvae larvae = new Larvae(this.health, this.age);
thisHive.get("a").bees.set(thisHive.get("a").beeIndex, larvae); //-------LINE 27
//thisHive.get("a").replaceBee(larvae) Line 27 was origionally this throwing the same exception
}
age++;
System.out.println("Egg" + " age " + this.age + " health " + this.health);
}
}
import java.util.ArrayList;
class Hive {
protected int honey;
protected int royalJelly;
protected int pollen;
public int beeIndex; // used to know what the index of bee …Run Code Online (Sandbox Code Playgroud) 我有一个循环运行,当它到达else语句时它应该停止运行.当我调试布尔功率确实更新但它仍然进入循环.我知道我可以使用System.Exit(0); 或休息; 但我会理解为什么它会继续运行错误的条件背后的逻辑?
public class Mmu {
//code omitted
public static final Mmu MMU = new Mmu();
public static void main(String[] args) {
MMU.runProcesses();
//code omitted
}
private Mmu() {
//code omitted
}
protected void runProcesses(){
boolean power= false; // running processes, normally this would start as false but I changed to test
boolean twoFinished = false;
boolean oneFinished = false;
while (power = true) { //still entering this when power = false why
twoFinished = MMU.processTwo.finished();
oneFinished = MMU.processOne.finished(); …Run Code Online (Sandbox Code Playgroud) 我正在尝试将a解析String为a Double并且由于对变量的限制,我必须以非常奇怪的方式执行此操作.目前我遇到的问题是两个函数都命名相同,但一个是a Double和另一个double.
public class Calculator {
Double x;
public Double x(String x){
//code ommited
x(Double.parseDouble(x.substring(x.lastIndexOf(" ") + 1, x.length())));
//^^ attempting to get this variable to be a Double instead of double
return new Double(x);
}
public Double x(Double x){
//code ommited
return new Double(0);
}
public Double x(double x){
//code ommited
return new Double(0);
}
}
Run Code Online (Sandbox Code Playgroud)