• 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:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Static Object

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
I have One doubt can anybody clear it
what is Static Object? What is the use of it
 
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sm,
It means that an entity is defined at compile time. So you can define static classes, methods and variables. As I know, you can�t have a static object because object is created during execution time. May be it is a miss with class and object terms.
If it is possible, I would like to know what "static object" means.
Adrian
 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can't create object of a static class. i.e you can't have an instance. For simplicity, let's take a static variable as an example.
public class example {
static int variable1 = 10;
}
In the memory it will retain its value till the end of the application. At some other point in code if you change
variable1 = 20;
then it will have a new value of 20 and it is retained. Moreover, you can access this variable example.variable1 and it doesn't need any instance.
Hope this helps..
deepa
 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
static methods and variabls r different from other normal varialbes and methods.
To use the Normal variables and methods we have to take the instance of the class first , but static varialbes r different, they make their place at compile time in the memory stack.
Static variables r used when u want to have a variable common to all instances of an object.. GOT IT ?
if not , ask me again i'll give u some example
Regards
Khurram Fakhar
 
reply
    Bookmark Topic Watch Topic
  • New Topic