-3

I came across this code in which I did not understand what static {} means:

public class BookProvider extends ContentProvider
{

private static final String TAG = "BookProvider";

private static HashMap<String, String> sBooksProjectionMap;
static
{
sBooksProjectionMap = new HashMap<String, String>();
sBooksProjectionMap.put(BookTableMetaData._ID,
BookTableMetaData._ID);

sBooksProjectionMap.put(BookTableMetaData.BOOK_NAME,

}
user3134565
  • 965
  • 1
  • 7
  • 14

1 Answers1

1

It's a static initializer. It's executed when the class is loaded (or initialized).

For more details please read http://docs.oracle.com/javase/tutorial/java/javaOO/initial.html

A Paul
  • 8,113
  • 3
  • 31
  • 61