• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Scott Selikoff
Bartenders:
  • Piet Souris
  • Jj Roberts
  • fred rosenberger

STATIC INITAILIZATION

 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
WHAT IS STATIC INITIALIZATION AND NON STATIC INITIALIZATION?
 
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by vinay17in:
WHAT IS STATIC INITIALIZATION AND NON STATIC INITIALIZATION?


Non Static inialization is the standard intitalization that you do by assignment of a class variable
class A{
int i = 10;
private static boolean debug = false;
...
or in a constructor
class A{
int i;
A(int k){
i = k;
static intialization is the intialization of static varables using a block of static code.
From Deitel&Dietel
A static initiaizer block allows complex initialization of a classes's static variables when the class is loaded.
The example that they use is to initalize a static array of gif images.
public A{
static ImageIcon c[];
static{
for(int i = 0 ; i < 5 ; i ++)
{
//get the images into the array
}//end for
}//end static code block
Hope this clears things up


[This message has been edited by Carl Trusiak (edited June 24, 2000).]
reply
    Bookmark Topic Watch Topic
  • New Topic