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

  • Home
  • SEARCH
  • 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 3340576
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:37:25+00:00 2026-05-18T00:37:25+00:00

Ordering Java methods is probably the least important code style issue ever, but I’m

  • 0

Ordering Java methods is probably the least important code style issue ever, but I’m trying to develop a code style as similar to what most people do as possible. It’s by far the most popular approach to first declare all fields and then all methods, so I’ll only ask about methods.

Now I’m wondering how to order Java methods. I can think of two sensible basic approaches:

  1. Order methods by visibility (i.e. first public, then protected, then private or the other way around)
  2. Order methods by dependency (i.e. if method a() calls method b(), put them as closely together as possible)

As far as I see it, the second approach seems to be more popular by far. Nonetheless, in both cases there is the question of the direction, and it is not as clear what most people use. In the second approach, you can either place a() above or below b(). I think placing b() above a() (and eventually main() at the bottom of the class file) is more common in C, not sure about C++. The other way around is IMO better for reading, from top to bottom. What’s the most common approach in Java? Any special rules about static fields/methods?

  • 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-05-18T00:37:25+00:00Added an answer on May 18, 2026 at 12:37 am

    I would generally prefer option 2 – with a class overview in the IDE showing public and private methods and auto-complete only showing the visible ones for a class, it does matter less though, as @Visage mentions.

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

Sidebar

Related Questions

I'm setting up an online ordering system but I'm in Australia and for international
I have a piece of code that I use to provide an implicit ordering
In Java, the class String implements Comparable, which means there's a total ordering on
Is it possible to maintain individual JFrame ordering? My java application populates individual JFrames
My list ordering appears fine in chrome and FF, but not in IE (all
Hi I got the following linq for ordering my input after lowest value. But
Is the SO tag ordering a good representation of programming language popularity? My first
How do I set tab ordering in WPF? I have an ItemsControl with some
I have a C++ STL set with a custom ordering defined. The idea was
A colleague and I are discussing best practices regarding ordering method parameters. The goal

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.