Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Java have a limit on the class name length?

This question came up in Spring class, which has some rather long class names. Is there a limit in the language for class name lengths?

like image 747
Eugene Katz Avatar asked Jun 24 '09 15:06

Eugene Katz


People also ask

How long can a Java class name be?

The specification of the programming language states that the length of a Java class name is unlimited. In practice, however, the first limit comes from the JVM specification. For the current JVM it's 65535 characters.

Can a class name have digits?

A class name is an identifier—a series of characters consisting of letters, digits, underscores ( _ ) and dollar signs ( $ ) that does not begin with a digit and does not contain spaces. Some valid identifiers are Welcome1 , $value , _value , m_inputField1 and button7 .

Can class name end with number in Java?

Java class names cannot start with numbers.

Can we use in Java class name?

You shouldn't use predefined or existing class names as the name of the current class. You shouldn't use any Java keywords as class name (with the same case). The First letter of the class name should be capital and remaining letters should be small (mixed case).


1 Answers

The Java Language Specification states that identifiers are unlimited in length.

In practice though, the filesystem will limit the length of the resulting file name.

like image 61
Robert Munteanu Avatar answered Sep 18 '22 22:09

Robert Munteanu