I am a beginner in java and trying to learn it by my own. my code is not working. can anybody please help me find out the error. Along with if anyone can tell me the best tutorials to learn java.
import java.util.Scanner;
public class TwentyQue {
public static void main(String args[]){
String first="", second="";
String x="animal",vegetable,mineral;
Scanner s=new Scanner(System.in);
System.out.println("TWO QUESTION!");
System.out.println("Think of an object, and I'll try to guess it.");
System.out.println("Is it animal, vegetable, or minaral?");
first=s.next();
if (first==x){
System.out.println("Is it bigger than a breadbox");
second=s.next();
if(second=="yes"){
System.out.println("My guess id that you are thinking of a mouse");
System.out.println("I would ask you but i really dont care.");
}else{
System.out.println("My guess id that you are thinking of a squirrel");
System.out.println("I would ask you but i really dont care.");
}
}else if (first=="vegetable"){
if(second=="yes"){
System.out.println("My guess id that you are thinking of a watermelon");
System.out.println("I would ask you but i really dont care.");
}else{
System.out.println("My guess id that you are thinking of a carrot");
System.out.println("I would ask you but i really dont care.");
}}else if (first=="mineral"){
if(second=="yes"){
System.out.println("My guess id that you are thinking of a Camero");
System.out.println("I would ask you but i really dont care.");
}else{
System.out.println("My guess id that you are thinking of a paper clip");
System.out.println("I would ask you but i really dont care.");
}
}
}
}