Reputation: 5804
What happens if we use a Java key word as our class name. In my case I created a class "Process". But I can not instantiate it. Is there a way to do it?
Upvotes: 0
Views: 634
Reputation: 1284
You cannot use Java keywords as identifiers in a Java program (to name a class, or a variable for example). However, you did not use a Java keyword, rather you named your class Process
just like the java.lang.Process
class. Since the java.lang.*
package is imported by default in any java class, that is why you cannot instantiate it.
If you really want to instantiate your own Process
class just refer to it with its fully qualified name, like: new my.package.Process(....)
.
But I advise you to change the name, it will give your code more clarity.
Upvotes: 3