I recently started learning java during my spare time. So to practice, I'm making a program that takes a temperature (Celsius or Fahrenheit) and converts it to the opposite. I've already imported the keyboard scanner.
int temp;
String opposite, type;
double product;
System.out.print("Please enter a temperature: ");
temp = keyboard.nextInt();
System.out.println("Was that in Celsius or Fahrenheit?");
System.out.print("(Enter 'C' for Celsius and 'F' for Fahrenheit) ");
type = keyboard.nextLine();
if (type == "C") // Only irrelevant temp conversion code left so I'm leaving it out
I'm new to the String and nextLine
stuff and the program just skips over the user input section where you enter either C or F. Would someone explain what I can do to fix this?
Thanks!