Harish Hansda
3 months ago
Harishcountry asked

Can we write class name with spaces in Java?

Abhay Jajodia
Expert
last month
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.