Java naming conventions are recommendations, rather than rules.
Naming conventions normally come as part of project standards; these are designed to ensure that the code is written in a consistent way across different areas of the project and also even within the same class of method.
After a certain amount of time a piece of code will have been written, then maintained by several different people. If everyone writes in a different way this code is going to become more and more difficult to read.
Think of it like a book that has been written by different people with different styles, you’re never quite sure who has written the next sentence. It would be very difficult to read, as each style will interrupt your flow.
Java code is the same, you only write it once but it will be read many times by you and your colleagues. It always pays to take the extra step to make it readable.
If the rules are broken the program will not compile; the Java compiler will complain. If the conventions are broken the program will still compile and run but it will be left to your boss and your colleagues to do the complaining.
This is a very important point to learn as a new developer. It’s one of the small things that are easy to ignore, but following the standards closely will help everyone around you and get you noticed as a careful developer who listens to requirements.
It is one of those hidden rules that in the long term is going to directly affect your bank balance. Writing code that is easy to read because it follows conventions will mark you out as someone who cares and someone who can be trusted. It is really in your best interests to follow best practices and follow the coding conventions wisely.
House style will change from project to project. When you join a new project it is very easy to slip into your style, normally the style you used on your last project. Make sure you read the coding conventions and pay careful attention to the areas where they are different to the way you are used to. Note these, so you can refer to them as necessary.
Ensure you use the new house style, not your style. If there are no coding conventions, be proactive: suggest creating some. It will help everyone in the long run and mark you out as someone who is proactive, and that’s never a bad thing.
Sun have a perfectly good set of coding conventions. This is a very good starting point for your coding conventions if you need them. You can use them just “as is” or document where you would like to deviate from these standards or just use Sun’s version.