class Main { public static void foo() { x = 4; } public static int x = 12; public static void main(String[] args) { int x = 24; foo(); System.out.println(x); } }
The foo function first creates a new variable x = 4 and then the main function creates a new variable x = 24.