Can someone explain me why "pyt11" take "yes" If I type it manually but if I take it from Scanner and put String "a" that doesn't see my variable.
From pyt11(a) (If I type "yes" in Scanner) gives me b value 0.
From pyt11("yes") gives me b value 20.
Someone knows why ?
public static Scanner into;
public static void main(String[] args)
{
into = new Scanner(System.in);
String a = into.nextLine();
System.out.println(a);
System.out.println(pyt11(a));
System.out.println(pyt11("yes"));
}
static int pyt11(String odp11)
{
int b = 0;
if (odp11 == "yes")
{
b = 20;
}
else if (odp11 == "maybe" || odp11 == "partially")
{
b = 10;
}
else if (odp11 == "no")
{
b = 0;
}
return b;
}