Hi, One simple scenario for you to understand this. Say you wanted to keep track of the number of instances created from a particular class.
public class MyClass { static int count = 0; public MyClass() { count++; } //................... } So using this "MyClass.count" anyone can check the number of instances created inside a program. Just a simple example. Cheers, Kamal http://lkamal.blogspot.com On Sun, Jan 24, 2010 at 9:34 AM, Sumit Bisht <sumitbisht1...@gmail.com>wrote: > Both Class and Instance variables address a different issue. > When working on class level, it is more easy to use a class variable > rather than instantiating an object for the same. > i.e. static <type> x is preferred than new <Object>().x > Also, in certain cases like the singleton pattern, it becomes > mandatory to do so to conform with the pattern. > > -- > sumit bisht > > -- > You received this message because you are subscribed to the Google > Groups "Java EE (J2EE) Programming with Passion!" group. > To post to this group, send email to > java-ee-j2ee-programming-with-passion@googlegroups.com > To unsubscribe from this group, send email to > java-ee-j2ee-programming-with-passion+unsubscr...@googlegroups.com<java-ee-j2ee-programming-with-passion%2bunsubscr...@googlegroups.com> > For more options, visit this group at > > http://groups.google.com/group/java-ee-j2ee-programming-with-passion?hl=en?hl=en > -- You received this message because you are subscribed to the Google Groups "Java EE (J2EE) Programming with Passion!" group. To post to this group, send email to java-ee-j2ee-programming-with-passion@googlegroups.com To unsubscribe from this group, send email to java-ee-j2ee-programming-with-passion+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/java-ee-j2ee-programming-with-passion?hl=en?hl=en