473,412 Members | 5,714 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

What is the meaning of "static" in Java

what is static
Sep 14 '10 #1
4 2651
Oralloy
988 Expert 512MB
@manu_verma,

The meaning of "static" depends on the context it is used in.

Have you tried reviewing how it is used from your Java books? They'll give you a good explanation.

Basically, though, it means that the memory location associated with the variable or method is statically composed - there is only one, and it is at a fixed location in memory. But that's a very abstract description.

Another idea you might consider is that static attributes have a lifespan of the enclosing class, where objects of the class have a lifespan determined by how they are used. Again, not very clear.

Then there's the concept of static inner classes. Which means that the class is named inside the outside class, but does not require a prototypical instance of the outer class in order to be instantiated.

Hopefully that helps, but it may well confuse you, too.
Sep 14 '10 #2
static is nothing but the constant value
Sep 15 '10 #3
Oralloy
988 Expert 512MB
@shreenath,

Ummm, I don't think so. The keyword "static" refers to how the entity is allocated. Plus, the keyword is overloaded somewhat, as a "static" class is not statically allocated, rather it is one which does not require an outer class object to be allocated.

The keyword "final" is the closest to the "constant" concept that Java has. A "final" attribute is one which is assigned at class load ("static" attributes) or object creation (others), and cannot be overridden. In that sense, the "final" attributes are constant. However the object referred to by a "final" attribute is not constant by any means. It is quite common for programmers to write code like this:
Expand|Select|Wrap|Line Numbers
  1. private final StringBuffer inBuffer = new StringBuffer();
Which means that inBuffer is assigned to a StringBuffer object that cannot be replaced. However, the class can perform any actions it wants against the StringBuffer.

Perhaps this article will help clarify things.

Of course, there is this proposal for adding "const"ness to java. However I think its flawed, in that "const" in the proposal applies to objects, but is declared for variables/attributes.
Sep 15 '10 #4
Dheeraj Joshi
1,123 Expert 1GB
static is nothing but the constant value
No it is not. Final keyword is used to for that.

Regards
Dheeraj Joshi
Sep 16 '10 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Ravi Tallury | last post by:
Hi We are having issues with our application, certain portions of it stop responding while the rest of the application is fine. I am attaching the Java Core dump. If someone can let me know what...
1
by: ptaz | last post by:
Hi I'm trying to run a web page but I get the following error. Ca anyone please tell me a solution to this. Thanks Ptaz HTTP Status 500 - type Exception report
11
by: DrUg13 | last post by:
In java, this seems so easy. You need a new object Object test = new Object() gives me exactly what I want. could someone please help me understand the different ways to do the same thing in...
0
by: mailkhurana | last post by:
Hii , I am trying to use a type 2 driver to connect to DB2 0n AIX 5 I have a small java test to class to establish a conneciton with the db .. I am NOT using WAS or any appserver When I try to...
1
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej...
12
by: Mark Fink | last post by:
I wrote a Jython class that inherits from a Java class and (thats the plan) overrides one method. Everything should stay the same. If I run this nothing happens whereas if I run the Java class it...
0
by: jaywak | last post by:
Just tried running some code on Linux (2.4.21-32.0.1.EL and Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_04-b05)) and Windows XPSP2 (with Java HotSpot(TM) Client VM (build...
1
by: jaimemartin | last post by:
hello, I want to validate an xml by means of a schema (xsd). To do that first of all I´m using a SchemaFactory. The problem is that if I run the code in Windows all works fine, but If I run it in...
0
oll3i
by: oll3i | last post by:
package library.common; import java.sql.ResultSet; public interface LibraryInterface { public ResultSet getBookByAuthor(String author); public ResultSet getBookByName(String name);
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.