Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8999233
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:09:10+00:00 2026-06-16T00:09:10+00:00

In Java code conventions, the instance variables should be placed before the methods or

  • 0

In Java code conventions, the instance variables should be placed before the methods or after the methods? I know, in the code convention of Oracle or Apache, they recommend the instance variables should be placed before the methods. However, in the book of Core Java, the authors place the instance variables after the methods. Hmm…maybe because of my C++ background, during my learning C++, I am educated that public functions should be placed before private members, because people care more about the functionality your code provide. Therefore, I want to know which is preferred way? If you can explain your reasons using your experiences of practical projects, that’s better.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T00:09:11+00:00Added an answer on June 16, 2026 at 12:09 am

    The normal Java convention is to put static variables first, instance variables, followed by constructors, and then the methods last.

    However, in the book of Core Java, the authors place the instance variables after the methods.

    You can always find people / books that don’t follow the normal conventions.

    Therefore, I want to know which is preferred way?

    See above.

    If you can explain your reasons using your experiences of practical projects, that’s better.

    No reason, apart from the fact that this is the accepted normal way of doing it, and writing code that goes against the normal conventions tends to make it less readable … for people who follow the normal conventions.

    It is possible that someone has done some empirical studies of code readability in which they measured relative readability. But I’ve never bothered to search them out.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was reading Code Conventions for Java from http://www.oracle.com/technetwork/java/javase/documentation/codeconventions-137265.html#587 . In that, they have
Should I stick with Sun's Java code conventions for PHP code?
When debugging Java code using Eclipse, for collection variables, I saw the modcount member.
We are having this discussion in our team about code conventions for Java for:
When rolling java code I've always stuck to the recommended convention of <reversed domain
I've just read the SUN java code conventions ; very nice document btw. And
in Java code convention is simple and obvious, in this style: public: int GetMyAge(){
Without having the source code for a Java API, is there anyway to know
Is there a CheckStyle rule file that checks against the Java Code Conventions from
This Java code compiles fine, but when I try to run it I get:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.