I have read a lot of Android code that looks like this, so many times:
public class MainActivity extends AppCompatActivity {
EditText editText;
TextView textView;
int someInt;
String someString;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//init views
}
}
I'm still kinda noob in Android programming, but as a classic Java programmer I don't understand why you would not encapsulate your fields as private and make them accessible via getters an setters if necessary. Is there any reason for this? Like some other class or activity in the same package needed direct access to the fields? It may be a silly question, but I couldn't find an explanation for this.