Results 1 to 3 of 3
Thread: static constuctor calls?!
- 02-13-2011, 01:02 PM #1
Member
- Join Date
- Feb 2011
- Posts
- 1
- Rep Power
- 0
- 02-13-2011, 01:48 PM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,398
- Blog Entries
- 7
- Rep Power
- 17
You don't 'call a class', you call (static) methods or constructors in a class or objects thereof. If you're talking about initialization code, yes, that code is only called once per class (static initialization) or per object (object initialization code).
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 02-13-2011, 05:43 PM #3
- Join Date
- Dec 2010
- Location
- Stockholm, Sweden
- Posts
- 222
- Blog Entries
- 9
- Rep Power
- 3
To clarify static initialisation is:
When a static variable is declared and assigned a value at declaration.
And
Java Code:static { //static initialisation code (nothing else than just static in the head) }
It is only run once (unless you unload the class, which you can do with jars).
A static class is a class declared within another class with a static modifier.
They behave exactly like outer classes.Ex animo! Hibernate
Java, Arch Linux, C, GPL v3, Bash, Eclipse, Linux VT, GNOME 2 and many buttons on windows.
Similar Threads
-
Can't make static reference to non-static method -> huh?! Simple car prgm
By enerj in forum New To JavaReplies: 7Last Post: 09-24-2010, 05:09 AM -
non-static method getType cannot be referenced from a static contex
By Dekkon0 in forum New To JavaReplies: 4Last Post: 05-12-2010, 11:05 AM -
non-static variable grade cannot be referenced from a static context
By pictianpravin in forum New To JavaReplies: 3Last Post: 02-11-2010, 09:59 AM -
Error: Non-static method append(char) cannot be referenced from a static context
By paul in forum Advanced JavaReplies: 1Last Post: 08-07-2007, 05:05 AM -
Error: non-static variable height cannot be referenced from a static context at line
By fernando in forum AWT / SwingReplies: 1Last Post: 08-01-2007, 09:25 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks