Harish Hansda
last year
Harishcountry asked

Can we write class name with spaces in Java?

Abhay Jajodia
Expert
last year
Abhay Jajodia answered

Hi Harish Hansda,

No, Java class names cannot contain spaces. A class name must be a single identifier.

If you want multiple words, write them together using CamelCase, like this:

class MyFirstClass {
}

If you have more questions, I am here to help 😊

Java
This question was asked as part of the Learn Java Basics course.