Hi there, is it valid to have a java class name and file as
public class DVD extends Items{ and
public class CD extends Items{ where its all in capitals?
-thanks, sorry for the short question.
Hi there, is it valid to have a java class name and file as
public class DVD extends Items{ and
public class CD extends Items{ where its all in capitals?
-thanks, sorry for the short question.
Brief follow-up to (and building on ’s point): Java allows class names to use all caps, so those identifiers are legal. The language enforces identifier rules (letters, digits, underscore, dollar sign; cannot start with a digit; cannot be a keyword) and the compiler enforces that a public top-level class must live in a .java file whose name exactly matches the class name (case included). Only one public top-level class is allowed per source file.
A small example of the filename ↔ class-name rule:
// file: MediaItem.java
public class MediaItem {
// top-level public class name must match the file name
} Conventions matter for readability and maintenance. The common practice is UpperCamelCase for class names; teams differ about acronyms (both XmlParser and XMLParser appear in real codebases). Package names should remain lowercase; constants (static final) use ALL_UPPERCASE_WITH_UNDERSCORES. Pick a convention early and apply it consistently across the project.
Practical cautions: case mismatches can be hidden on case-insensitive filesystems (Windows) but will break on case-sensitive systems (Linux) or CI. Runtime errors like ClassNotFoundException or NoClassDefFoundError often trace back to filename/package/case mismatches or incorrect classpath layout. When changing capitalization under Git on Windows, ensure commits actually register the rename (Git sometimes needs an explicit rename to update case).
Jump to Post— JamesCherrill 4,733Yes, that's OK.
Yes, that's OK.
oh rite. thanks.
No problem. The Java coding standard just says the class names should begin with a capital letter, but if you have deeper questions about Java coding standards or conventions I recommend that you use the Java API as your guide - that's a huge amount of code that demonstrates every variation youu will ever need.
So, for example, you will see that the API includes classes like: CRC32, CSS and URL. You can safely conclude that if the class name is an ancronym that's normally capitalised, it's appropriate to capitalise the class name in the same way.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.