Why compiler gives me error when I call object MyObject ?

public class ThisIsClass 
    public static void main(String[] args)
        MyObject loan = new MyObject();  //error should be ThisIsClass loan = new ThisIsClass(); 

It works fine when I change name of my class to MyObject or change object name?
Why I can't use object on my own name ?

Thanks for quick explanation

That's strange. The setup works for me...

Where's your MyObject class?

Well, by applying "... loan = new ..." you want to create an instance (object) of a class. The only class in your file ThisIsClass.java seems to be ThisIsClass. So you can only apply ThisIsClass loan = new ThisIsClass();.

If you want to use type MyObject as a class name, you must have a class like class MyObject { ... } stored in your file ThisIsClass.java or elsewhere yet reachable by the compiler.

I think there is something of a misconception, for your chosen name MyObject suggest that you want to have an instance (= object) of a class. For object is just another name for instance (synonym) maybe this is more situable: ThisIsClass myObject = new ThisIsClass();.

This question has already been answered. Start a new discussion instead.