Say I have something like this in a C Code. I know you can use a #define
instead, to make the compiler not compile it, but just out of curiosity I\'m asking if
Instead of asking such simple questions (where the only correct answer is "Try it out with your compiler") - why not just try it?
public class Test {
public static void main(String[] args) {
if (true) {
System.out.println("Yep");
}
boolean var = false;
if (var) {
System.out.println("Nope");
}
final boolean var2 = false;
if (var2) {
System.out.println("Nope");
}
}
}
javac .\Test.java
javap -c Test
Compiled from "Test.java"
public class Test {
public Test();
Code:
0: aload_0
1: invokespecial #1 // Method java/lang/Object."<init>":()V
4: return
public static void main(java.lang.String[]);
Code:
0: getstatic #2 // Field java/lang/System.out:Ljava/io/PrintStream;
3: ldc #3 // String Yep
5: invokevirtual #4 // Method java/io/PrintStream.println:(Ljava/lang/String;)V
8: iconst_0
9: istore_1
10: iload_1
11: ifeq 22
14: getstatic #2 // Field java/lang/System.out:Ljava/io/PrintStream;
17: ldc #3 // String Yep
19: invokevirtual #4 // Method java/io/PrintStream.println:(Ljava/lang/String;)V
22: return
}
You don't need to know much about java/c# bytecode or assembly to be able to understand what's going on. And now go and try the same for C#..