473,385 Members | 1,907 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,385 software developers and data experts.

Static variable initailization

Hi There,
I'm new to Java. Having read a bunch of books, I wonder if static
variable is initailized by defualt value? Textbooks only indicate that
instance variable is implicitly initailized.

Thanks in advance,
Black Java
(Student from city of angel)
Jul 17 '05 #1
2 9361
Black Java wrote:
Hi There,
I'm new to Java. Having read a bunch of books, I wonder if static
variable is initailized by defualt value? Textbooks only indicate that
instance variable is implicitly initailized.


Static variables are actually called class variables in Java.

Section 4.5.5 in the Java Language Specification, 2nd edition, states:
"Each class variable, instance variable, or array component is initialized
with a default value when it is created"

See
<http://java.sun.com/docs/books/jls/second_edition/html/typesValues.doc.html#96595>
for more information.

--
Jonas Kongslund
Jul 17 '05 #2
nos
watch out because "local" variables are not initialized

"Jonas Kongslund" <do**@mail.me.at.all> wrote in message
news:fw*****************@news.get2net.dk...
Black Java wrote:
Hi There,
I'm new to Java. Having read a bunch of books, I wonder if static
variable is initailized by defualt value? Textbooks only indicate that
instance variable is implicitly initailized.
Static variables are actually called class variables in Java.

Section 4.5.5 in the Java Language Specification, 2nd edition, states:
"Each class variable, instance variable, or array component is

initialized with a default value when it is created"

See
<http://java.sun.com/docs/books/jls/s...alues.doc.html
#96595> for more information.

--
Jonas Kongslund

Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Datta Patil | last post by:
Hi , #include<stdio.h> func(static int k) /* point2 : why this is not giving error */ { int i = 10 ; // static int j = &i ; /* point 1: this will give compile time error */ return k; } /*...
9
by: AnandRaj | last post by:
Hi guys, I have a few doubts in C. 1. Why static declartions are not allowed inside structs? eg struct a { static int i; }; Throws an error ..
28
by: Dennis | last post by:
I have a function which is called from a loop many times. In that function, I use three variables as counters and for other purposes. I can either use DIM for declaring the variables or Static. ...
6
by: Vladislav Kosev | last post by:
I have this strange problem now twice: I am writing this relatevely large web site on 2.0 and I made a static class, which I use for url encoding and deconding (for remapping purposes). This static...
55
by: Zytan | last post by:
I see that static is more restricted in C# than in C++. It appears usable only on classes and methods, and data members, but cannot be created within a method itself. Surely this is possible in...
10
by: Pramod | last post by:
Hello to all of you, I want to know that what's the use to create static object. Thanks You Pramod Sahgal
3
by: Richard K Miller | last post by:
Here's an OOP question that perplexes me. It seems PHP doesn't treat static variables correctly in child classes. <?php class ABC { public $regular_variable = "Regular variable in ABC\n";...
37
by: minkoo.seo | last post by:
Hi. I've got a question on the differences and how to define static and class variables. AFAIK, class methods are the ones which receives the class itself as an argument, while static methods...
16
by: RB | last post by:
Hi clever people :-) I've noticed a lot of people stating not to use static variables with ASP.NET, and, as I understand it, the reason is because the variable is shared across user sessions -...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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...

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.