Skip to content

Instantly share code, notes, and snippets.

@rtomaszewski
Created August 9, 2012 21:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rtomaszewski/3308394 to your computer and use it in GitHub Desktop.
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
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