File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes What does the Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "What does the "static" block in following class does?" Watch "What does the "static" block in following class does?" New topic
Author

What does the "static" block in following class does?

Pras Tiwari
Ranch Hand

Joined: Nov 07, 2005
Posts: 186
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
SCJP 1.4, SCWCD 1.4
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What does the "static" block in following class does?
 
Similar Threads
request.getHeader() return value ?
if statement with Apache commons upload
What is the Need for embed an Image in a Flex Application??
Image to String to Image in a email
getOutputStream() has already been called for this response