Reputation: 3373
1) when the lifetime of static nested class in Java begins? can static inner class be used before creation of the containing object?
I'm asking because I encountered the code:
LinearLayout.LayoutParams layoutParams1 = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
and I tried to answer the question:
2) what is LayoutParams to LinearLayout?
anyway if what I suspect doesn't relate to the syntax I would like to get answers for both 1 & 2.
Upvotes: 3
Views: 313
Reputation: 135992
An instance of a static nested class can be created without creating an instance of its outer class.
"static inner class" is an incorrect expression. JLS 8.1.3: An inner class is a nested class that is not explicitly or implicitly declared static.
LayoutParams is a static nested class of LinearLayout. LinearLayout is outer class of LayoutParams
Upvotes: 4