Reputation: 171
Can anyone explain me,
public class Class10 {
public String i=" ";
public String j;
j=" "; //Does-Not work
public void method(String[] args){
public String k=" "; // Does-not work
j=" ";
}
}
Upvotes: 0
Views: 203
Reputation: 31225
1) It is possible with the right syntax (but discouraged) :
public class Class10 {
public String i=" ";
public String j;
{j=" ";} //This is called an "Instance initialization block"
//It would be better to do it in a constructor.
2) It does not make sense :
Upvotes: 4