Q:

Java code suddenly stop

Ive got a problem.I 'm new to Java,I've started today:D) ..I've programmed before so I know it little bit,but I am new to Java. Here is my code: `    
public class Tutorial {

public static void main(String[] args) {
    double num1,num2;
    String operacia;
    Scanner in=new Scanner (System.in);
    System.out.println("Write 2 numbers");
    num1=in.nextDouble();
    num2=in.nextDouble();
    System.out.println("Choose the operation");
    operacia=in.nextLine();
    if (operacia.equals("+")){
        System.out.println("Your result is "+(num1+num2))   ;
    }
    else if (operacia.equals("-")){
        System.out.println("Your result is  "+(num1-num2))  ;
    }
    else if (operacia.equals("/")){
        System.out.println("Your result is  "+(num1/num2))  ;
    }
    else if (operacia.equals("*")){
        System.out.println("Your result is  "+(num1*num2))  ;
    }

}
}` 

It wants from me 2 numbers,I write them and them it writes "Choose the operation" and its over.No more inputs.Thank you very much :)

A:

Your problem is simple. 
Just replace the code with next() instead of nextLine().Effectively, the line your code is returning is receiving is a blank line. Hence when it reaches the conditional statement it has an empty string and terminates.
next()
Finds and returns the next complete token from this scanner.

nextLine()
Advances this scanner past the current line and returns the input that was skipped.

Your code should be fixed by a simple change.
public static void main(String[] args) {
    double num1,num2;
    String operacia;

    Scanner in=new Scanner (System.in);
    System.out.println("Write 2 numbers");

    num1=in.nextDouble();
    num2=in.nextDouble();

    System.out.println("Choose the operation");
    operacia=in.next();

    if (operacia.equals("+")){
        System.out.println("Your result is "+(num1+num2))   ;
    }
    else if (operacia.equals("-")){
        System.out.println("Your result is  "+(num1-num2))  ;
    }
    else if (operacia.equals("/")){
        System.out.println("Your result is  "+(num1/num2))  ;
    }
    else if (operacia.equals("*")){
        System.out.println("Your result is  "+(num1*num2))  ;
    }
}

