View view1 = findViewById(R.id.myView1); View view2 = findViewById(R.id.myView2); if (view1.equals(view2)) { // the two views are equal } else { // the two views are not equal }
View view = findViewById(R.id.myView); if (view != null && view.equals(null)) { // the view is not null and it is not equal to null } else { // the view is either null or it is equal to null }Package Library: The `android.view.View` class is part of the Android framework package `android.view`.