Why is the following code compiling but not starting?

class Demo { Demo() { System.out.println("Hello From Demo"); } } class demo { demo() { System.out.println("Hello From Small Demo"); } } class Test { public static void main(String arg[]) { Demo d1=new Demo(); demo d2=new demo(); } } 

This code compiles but does not run; When I try to run this program, it gives a classNotFoundException . What am I doing wrong?

+4
source share
1 answer

On Unix and / or .jar compiled into an application, file names are case sensitive. And everything will work: demo.class, Demo.class.

On Windows, compiling the demo and Demo will overwrite one file.

+12
source

Source: https://habr.com/ru/post/1496127/


All Articles