| Author |
What does the "static" block in following class does?
|
Pras Tiwari
Ranch Hand
Joined: Nov 07, 2005
Posts: 185
|
|
Hi, I have static block as follows in my java class:- public class SimpleWeb extends Thread { static { String image = "image/"; MIME_TYPES.put(".gif", image + "gif"); MIME_TYPES.put(".jpg", image + "jpeg"); MIME_TYPES.put(".jpeg", image + "jpeg"); MIME_TYPES.put(".png", image + "png"); String text = "text/"; MIME_TYPES.put(".html", text + "html"); MIME_TYPES.put(".htm", text + "html"); MIME_TYPES.put(".txt", text + "plain"); } //other methods in class } What does this static block does?? Thanks in advance. Pras
|
********Deserve Before You Desire********
|
 |
Leandro Melo
Ranch Hand
Joined: Mar 27, 2004
Posts: 401
|
|
Hi. It guarantees that when your class is loaded, the member MIME_TYPES is filled with the values being set. It's just a way to soon initialize the MIME_TYPES member.
|
Leandro Melo <br />SCJP 1.4, SCWCD 1.4<br /><a href="http://www.pazbrasil.org/" target="_blank" rel="nofollow">http://www.pazbrasil.org/</a>
|
 |
 |
|
|
subject: What does the "static" block in following class does?
|
|
|