How to resolve a Nullpointer exception? : I am using two Recyclerviews in my app, one in the MainActivity and one in another activity. The one in the MainActivity works fine but the other has a NullpointerException and I don't know where the problem is.

I know what this problem causes but I don't see it in my code. Here is a code snippet of the second Recyclerview, where Logcat says that there is a Null object reference. I used the same code as the first Recyclerview where everything works (I changed of course the names in this file)

The error message says that there is a problem in this line: recyclerView.setLayoutManager(layoutManager);

and in this line
initRecyclerViewFreundesUebersicht();

```private void initRecyclerViewFreundesUebersicht() {

        LinearLayoutManager layoutManager = new LinearLayoutManager(this, RecyclerView.VERTICAL, false);
        RecyclerView recyclerView = findViewById(R.id.recyclerViewFreundesUebersicht);
        recyclerView.setLayoutManager(layoutManager);
        RecyclerViewAdapterFreundesUebersicht adpater = new RecyclerViewAdapterFreundesUebersicht(mNames, mImageUrls, this);
        recyclerView.setAdapter(adpater);
    }

@Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_spielen_uebersicht);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        init();
        initRecyclerViewFreundesUebersicht();
        getImages();
    }
