dimanche 28 juin 2020

Java If statment problem with Scanner and trying to read user input [duplicate]

I am brand new to Java moving from Python, can someone explain what I need to be doing differently to make this code work? This is my first Java project, I am trying to make a very simple calculator to get an understanding of the basics.

import java.util.Scanner;
public class calculatortest {

    private static Scanner scan;

    public static void main(String args[]) {

        //This is a test for a calulator to see if I can code this without any help. 

        Scanner typeofcalc = new Scanner(System.in);

        System.out.println("What type of calculation would you like to do?: ");

        String calctype = typeofcalc.nextLine();
        if calctype == "add", "addition"{
            
        }
        
    }
    
}

Aucun commentaire:

Enregistrer un commentaire