Created
August 9, 2012 21:56
-
-
Save rtomaszewski/3308394 to your computer and use it in GitHub Desktop.
Simple java code showing that before we can assign value to variable it has to be known to the javac compiler in advance
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class JavaExample { | |
// with the next line commented the code is erroring out when we try to compile it | |
//public int number; | |
public JavaExample (int _number) { | |
number=_number; | |
} | |
public void show() { | |
System.out.println("[test " + number + "] list=%s"); | |
} | |
public static void main(String[] args) { | |
JavaExample t=new JavaExample(1); | |
t.show(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment