Link to home
Start Free TrialLog in
Avatar of KPax
KPax

asked on

Why method in Java which is called from Runnable run() doesn't need to be 'static'?

Why this compiles, even if fooBar is NOT static?

public class TestClass implements Runnable {

	public static void main(String[] args) {
		// TestClass tc = new TestClass();
	}

	@Override
	public void run() {
		fooBar();
	}

	private void fooBar() {
		System.out.println("fooBar");
	}
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of CPColin
CPColin
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial