I was trying to show that I know the basics of Python with this piece of code, and it works:
x = 2
y = 4
foo = x+1
bar = y-1
S = 'SUCCESS'
F = 'FAILURE'
def myFunction() :
if (foo == bar):
return(True)
else:
return(False)
if myFunction():
print(S)
else:
print(F)
I also wanted to show my knowledge of the basics of Java with this piece of code, but it doesn't work:
public class Main {
public static void main(String[] args) {
int x = 2;
int y = 4;
int foo = x + 1;
int bar = y - 1;
String S = "SUCCESS";
String F = "FAILURE";
myMethod();
}
static void myMethod() {
if (foo == bar) {
System.out.println(S);
} else {
System.out.println(F);
}
}
}
I'm confused, because this one does work:
public class Main {
public static void main(String[] args) {
int x = 2;
int y = 4;
int foo = x + 1;
int bar = y - 1;
String S = "SUCCESS";
String F = "FAILURE";
if (foo == bar) {
System.out.println(S);
} else {
System.out.println(F);
}
}
}
Do you guys know what's wrong?