Java: Instantiate an innerclass from the main constructor does not work.

public class Main
{
	public static void main(String[] args)
	{
		Test t = new Test();

		System.out.println(t.getInt());
	}

	public class Test
	{
		public Test()
		{
		}

		public int getInt()
		{
			return 5;
		}
	}
}

While it works in C#:

class Program
{
	static void Main(string[] args)
	{
		Test t = new Test();

		Console.WriteLine(t.GetInt());

		Console.ReadLine();
	}

	public class Test
	{
		public Test()
		{
		}

		public int GetInt() 
		{ 
			return 5; 
		}
	}
}

If you move the class in Java to a seperate file it (obviously) works. But why? No idea.