<p>What characters are valid in a Java class name? What other rules govern Java class names (for instance, Java class names cannot begin with a number)?</p>

[{'answer_id': 65490, 'author': 'Jason Cohen', 'author_id': 4926, 'author_profile': 'https://Stackoverflow.com/users/4926', 'pm_score': 7, 'selected': True, 'text': '<p>You can have almost any character, including most Unicode characters!  The exact definition is in <a href="http://docs.oracle.com/javase/specs/jls/se7/html/jls-3.html#jls-3.8" rel="noreferrer">the Java Language Specification under section 3.8: Identifiers</a>.</p>\n<blockquote>\n<p>An <em>identifier</em> is an unlimited-length sequence of <em>Java letters</em> and <em>Java digits</em>, the first of which must be a <em>Java letter</em>. ...</p>\n<p>Letters and digits may be drawn from the entire Unicode character set, ... This allows programmers to use identifiers in their programs that are written in their native languages.</p>\n<p>An identifier cannot have the same spelling (Unicode character sequence) as a keyword (§3.9), boolean literal (§3.10.3), or the null literal (§3.10.7), or a compile-time error occurs.</p>\n</blockquote>\n<p>However, see <a href="https://stackoverflow.com/questions/61615/should-you-use-international-identifiers-in-javac">this question</a> for whether or not you should do that.</p>\n'}, {'answer_id': 65531, 'author': 'Ivan Bosnic', 'author_id': 3221, 'author_profile': 'https://Stackoverflow.com/users/3221', 'pm_score': 4, 'selected': False, 'text': '<blockquote>\n  <p>Every programming language has its own set of rules and conventions for the kinds of names that you\'re allowed to use, and the Java programming language is no different. The rules and conventions for naming your variables can be summarized as follows:</p>\n  \n  <ul>\n  <li><p>Variable names are case-sensitive. A variable\'s name can be any legal identifier — an unlimited-length sequence of Unicode letters and digits, beginning with a letter, the dollar sign "$", or the underscore character "_". The convention, however, is to always begin your variable names with a letter, not "$" or "_". Additionally, the dollar sign character, by convention, is never used at all. You may find some situations where auto-generated names will contain the dollar sign, but your variable names should always avoid using it. A similar convention exists for the underscore character; while it\'s technically legal to begin your variable\'s name with "_", this practice is discouraged. White space is not permitted.</p></li>\n  <li><p>Subsequent characters may be letters, digits, dollar signs, or underscore characters. Conventions (and common sense) apply to this rule as well. When choosing a name for your variables, use full words instead of cryptic abbreviations. Doing so will make your code easier to read and understand. In many cases it will also make your code self-documenting; fields named cadence, speed, and gear, for example, are much more intuitive than abbreviated versions, such as s, c, and g. Also keep in mind that the name you choose must not be a keyword or reserved word.</p></li>\n  <li><p>If the name you choose consists of only one word, spell that word in all lowercase letters. If it consists of more than one word, capitalize the first letter of each subsequent word. The names gearRatio and currentGear are prime examples of this convention. If your variable stores a constant value, such as <code>static final int NUM_GEARS = 6</code>, the convention changes slightly, capitalizing every letter and separating subsequent words with the underscore character. By convention, the underscore character is never used elsewhere. </p></li>\n  </ul>\n</blockquote>\n\n<p>From <a href="https://docs.oracle.com/javase/tutorial/java/nutsandbolts/variables.html" rel="nofollow noreferrer">the official Java Tutorial</a>.</p>\n'}, {'answer_id': 65955, 'author': 'MetroidFan2002', 'author_id': 8026, 'author_profile': 'https://Stackoverflow.com/users/8026', 'pm_score': 2, 'selected': False, 'text': "<p>I'd like to add to bosnic's answer that any valid currency character is legal for an identifier in Java.  th€is is a legal identifier, as is €this, and € as well.  However, I can't figure out how to edit his or her answer, so I am forced to post this trivial addition.</p>\n"}, {'answer_id': 66194, 'author': 'Garth Gilmour', 'author_id': 2635682, 'author_profile': 'https://Stackoverflow.com/users/2635682', 'pm_score': 4, 'selected': False, 'text': '<p>Further to previous answers its worth noting that:</p>\n\n<ol>\n<li>Java allows any Unicode currency symbol in symbol names, so the following will all work:</li>\n</ol>\n\n<blockquote>\n  <p>$var1\n  £var2\n  €var3</p>\n</blockquote>\n\n<p>I believe the usage of currency symbols originates in C/C++, where variables added to your code by the compiler conventionally started with \'$\'. An obvious example in Java is the names of \'.class\' files for inner classes, which by convention have the format \'Outer$Inner.class\'</p>\n\n<ol start="2">\n<li>Many C# and C++ programmers adopt the convention of placing \'I\' in front of interfaces (aka pure virtual classes in C++). This is not required, and hence not done, in Java because the implements keyword makes it very clear when something is an interface.</li>\n</ol>\n\n<p>Compare:</p>\n\n<blockquote>\n  <p>class Employee : public IPayable //C++</p>\n</blockquote>\n\n<p>with</p>\n\n<blockquote>\n  <p>class Employee : IPayable //C#</p>\n</blockquote>\n\n<p>and </p>\n\n<blockquote>\n  <p>class Employee implements Payable //Java</p>\n</blockquote>\n\n<ol start="3">\n<li>Many projects use the convention of placing an underscore in front of field names, so that they can readily be distinguished from local variables and parameters e.g.</li>\n</ol>\n\n<blockquote>\n  <p>private double _salary;</p>\n</blockquote>\n\n<p>A tiny minority place the underscore after the field name e.g.</p>\n\n<blockquote>\n  <p>private double salary_;</p>\n</blockquote>\n'}, {'answer_id': 11209443, 'author': 'EriF89', 'author_id': 1458499, 'author_profile': 'https://Stackoverflow.com/users/1458499', 'pm_score': 3, 'selected': False, 'text': '<p>As already stated by Jason Cohen, the Java Language Specification defines what a legal identifier is in section 3.8:</p>\n\n<p>"An identifier is an unlimited-length sequence of Java letters and Java digits, the\nfirst of which must be a Java letter. [...] A \'Java letter\' is a character for which the method Character.isJavaIdentifierStart(int) returns true. A \'Java letter-or-digit\' is a character for which the method Character.isJavaIdentifierPart(int) returns true."</p>\n\n<p>This hopefully answers your second question. Regarding your first question; I\'ve been taught both by teachers and (as far as I can remember) Java compilers that a Java class name should be an identifier that begins with a capital letter A-Z, but I can\'t find any reliable source on this. When trying it out with OpenJDK there are no warnings when beginning class names with lower-case letters or even a $-sign. When using a $-sign, you do have to escape it if you compile from a bash shell, however.</p>\n'}, {'answer_id': 28011680, 'author': 'Sachin Tiwari', 'author_id': 3792421, 'author_profile': 'https://Stackoverflow.com/users/3792421', 'pm_score': 0, 'selected': False, 'text': '<p>Class names should be nouns in UpperCamelCase, with the first letter of every word capitalised. Use whole words — avoid acronyms and abbreviations (unless the abbreviation is much more widely used than the long form, such as URL or HTML).\nThe naming conventions can be read over here:</p>\n\n<p><a href="http://www.oracle.com/technetwork/java/codeconventions-135099.html" rel="nofollow">http://www.oracle.com/technetwork/java/codeconventions-135099.html</a></p>\n'}, {'answer_id': 39371169, 'author': 'navneet kumar', 'author_id': 6804950, 'author_profile': 'https://Stackoverflow.com/users/6804950', 'pm_score': 0, 'selected': False, 'text': '<p>Identifiers are used for class names, method names, and variable names. An identifiermay be any descriptive sequence of uppercase and lowercase letters, numbers, or theunderscore and dollar-sign characters. They must not begin with a number, lest they beconfused with a numeric literal. Again, Java is case-sensitive, so VALUE is a differentidentifier than Value.\nSome examples of valid identifiers are:</p>\n\n<p>AvgTemp ,count a4 ,$test ,this_is_ok</p>\n\n<p>Invalid variable names include:</p>\n\n<p>2count, high-temp, Not/ok</p>\n'}, {'answer_id': 42319629, 'author': 'Deepak Kumar', 'author_id': 6214316, 'author_profile': 'https://Stackoverflow.com/users/6214316', 'pm_score': 1, 'selected': False, 'text': '<blockquote>\n  <p>What other rules govern Java class names (for instance, Java class names cannot begin with a number)?</p>\n</blockquote>\n\n<ul>\n<li>Java class names usually begin with a capital letter.</li>\n<li>Java class names cannot begin with a number.</li>\n<li>if there are multiple words in the class name like "MyClassName" each word should begin with a capital letter. eg- "MyClassName".This naming convention is based on <strong>CamelCase</strong> Type.</li>\n</ul>\n'}]
['https://Stackoverflow.com/questions/65475', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/8720/']