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 577329
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:08:31+00:00 2026-05-13T14:08:31+00:00

In Java, the name of the file should be the same as the name

  • 0

In Java, the name of the file should be the same as the name of the public class contained in that file. Why is this a limitation? What purpose does it serve?

  • 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-13T14:08:32+00:00Added an answer on May 13, 2026 at 2:08 pm

    Java had an interesting approach: where giving a programmer a choice can only degrade the programming experience, remove the choice.

    They did this in quite a few places. Filenames and packages for sure, but also not allowing multiple public classes in a file (never good), not allowing you to split classes between files (Damn hard to work with!), etc.

    Languages make a lot of decisions like this, they all affect usability and maintainability. Some others that might have been good choices:

    Public variables: I’ve never needed one, nor have I ever seen a situation where some smart programmer thought one was needed and was actually right.

    Method/class size limitations would be great, but this could get sketchy (it could easily be implemented by code checkers, the problem is typically that the companies that need the most help are the ones that don’t know they need help and, therefore, don’t use tools like code checkers).

    The point of the answer is that although isn’t stuff that matters to most small teams, when your team grows and has multiple sites with split teams and consultants throughout the world, You really to appreciate the inflexibility.


    In response to setters/getters comment:

    Java beans were an abomination created by Borland to hack their GUI up, then retrofitted into Java.

    Horrid idea–a distraction from OO programming–Getters and setters A) show too much of your implementation and B) make you think in terms of operating on data from another object rather than asking the other object to execute an operation for you. Bad hack for people who can’t yet think in OO.

    Getters are needed occasionally but shouldn’t be added unless seen to be absolutely unavoidable.

    Setters should be avoided at all costs. If you absolutely need to externally modify the state after an object is constructed, try to use the builder pattern and protect your setters from being called after any operation has been executed.

    There are obviously exceptions to everything, and many "Getters" are actually critical object business logic, like String.length() which would be required no matter how String was implemented and isn’t even implemented by just returning a property–a great case for a "Getter" if you even want to call it that.

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

Sidebar

Ask A Question

Stats

  • Questions 357k
  • Answers 357k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The other answers are correct. Here is some code you… May 14, 2026 at 9:40 am
  • Editorial Team
    Editorial Team added an answer you ruin the noConflict concept by reassigning the jquery to… May 14, 2026 at 9:40 am
  • Editorial Team
    Editorial Team added an answer If you get that particular error, you don't actually have… May 14, 2026 at 9:40 am

Related Questions

No related questions found

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.