skip to Main Content

So whenever I build and test my maven package i am not getting an output and the program auto closes, I have tried this on Eclipse and Netbeans and still no heed, thanks in advance and the code is below:

public static void main(String[] args) {
    // TODO Auto-generated method stub

    Boolean end = false;
    while(end = false){
    System.out.println("Enter your command(for list of commands press h): ");
    Scanner scanner = new Scanner(System.in);
    String command = scanner.nextLine();
    if(command == "h"){
        System.out.println("start   starts basic program");
        System.out.println("start1  starts twitter based program(in development)");
        System.out.println("api     sets api");
        System.out.println("time     sets check time");

    }else if( command == "start"){
        mainmethod();
    }else if(command == "time"){

    }else if( command == "end"){
                end = true;
            }
    }


}

2

Answers


  1. your code means:

    while(false){.....} 
    

    Please change from:

    while(end = false){
    ......
    }
    

    into:

    while(end == false){
    ......
    }
    
    Login or Signup to reply.
  2. It’s “==” rather than “=”.end == false

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search