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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:17:48+00:00 2026-06-15T15:17:48+00:00

i am confused about the usage of static methods in java , for example

  • 0

i am confused about the usage of static methods in java , for example it makes sense if main method is static , but while coding we have got objects for example

 JFrame frame= new JFrame(); 
 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);// here why not frame.EXIT_ON_CLOSE

and same way when we use

 GridBagConstraints c= new GridBagConstraints();// we have an object but still
 c.anchor = GridBagConstraints.PAGE_END; 

so can anyone please explain me the is there any special reasons for it ?

  • 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-15T15:17:49+00:00Added an answer on June 15, 2026 at 3:17 pm

    Static methods and fields belong to all objects in a class, as opposed to non-static ones, which belong to a particular instance of a class. In your example, no matter how many JFrame frame objects you create, accessing frame.EXIT_ON_CLOSE would produce the same exact result. To state this fact explicitly, static members (also known as “class members”) are used.

    Same logic applies to static methods: if a method does not access instance variables, its result becomes independent of the state of your object. The main(String[] args) method is one such example. Other common examples include various factory methods, parsing methods for primitives, and so on. These methods do not operate on an instance, so they are declared static.

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

Sidebar

Related Questions

I am a bit confused about the need and usage of the yield method.
I am confused by the documentation about the usage syntax-case, but what can f
I am a little confused about the usage of cells and arrays in MATLAB
I am a little confused about Accept-Encoding . I have Web Service which would
I am a little confused about the roles of a java application server and
I have read about POCO (Plain old CLR (or C#) object) here ,and confused
I implemented a plugable framework like below. It works but I'm confused about the
I'm a bit confused about the usage of Abstract classes in C#. In C++,
I am bit confused about the difference between the usage of std::remove algorithm. Specifically
I'm a bit confused about the use of Vim's menus. I have set wildmenu

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.