Search code examples
javacoding-style

Is there a coding standard for Java?


I can develop an application/project. But that is not in the correct coding standard. it takes large memory and others can not be understand it easily. What the General Standard to for coding. I have a question like how to name the variables methods & what is the best way to package the classes. like that?

For that, is there any tutorial or example please share .

Thanks in Advance.


Solution

  • What you need are the best-practices (JAVA) and how it works.

    I will recommend an older post

    as Macarse said:

    Have you read Effective Java? http://java.sun.com/docs/books/effective/

    There is a good amount of good code in it.

    To learn how things are done (in the best way) I'll recommend to always check other people's code, especially the open source projects.

    You can always check the jdk source code, there are some good algorithms around it: http://java.sun.com/j2se/1.5.0/source_license.html

    Also, sometimes I use to research some good open source apps code...

    edited: Also is a good idea to participate in communities like this....

    Check this out: http://www.javadb.com/

    as Naiku said:

    The best option for you to study good code is to look at some popular open source projects. I think 2 years is good enough time to understand code in these projects. Some of the projects you could look at:

    * openjdk
    * apache tomcat
    * spring framework
    * apache commons (very useful)
    * Google collections
    

    Enough for you to study and understand a variety of concepts. I frequently study code in JDK catalina(tomcat), spring, jboss, etc.

    For Java Memory Management see this Question