0

is there any difference if use

public class SplashActivity extends Activity {

private Textview xxxx;

@override
protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.activity_main);


xxxx = findViewById(R.id.text_view_id); 

or like this


public class SplashActivity extends Activity {

Textview xxxx;

@override
protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.activity_main);


xxxx = findViewById(R.id.text_view_id);  

what is the difference if use private in front of TextView

  • 1
    Right it is accessible from any class by creating object means we can change its behavior anytime in any place but as per coding guidelines we should restrict our resources as per the need as you will only use this object in this class only so mark it as Private. – Nitesh Sharma Jun 16 '20 at 21:40
  • got the idea. thank you – StudyFromHome Jun 17 '20 at 05:06

0 Answers0