Can't figure out what crashes the app with ArrayAdapter?

Want to display a list of names. The application is about, but on the emulator immediately crashes.
package com.example.arraylist;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import java.util.List;

public class MainActivity extends AppCompatActivity {

 private List<String> list;
 private ArrayAdapter<String> adapter;

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

list.add("Dima");
list.add("Anton");
list.add("Stas");
list.add("Pasha");

 adapter = new ArrayAdapter<>(this, R. layout.array_adapter, list);

 ListView lv = (ListView)findViewById(R. id.listView);
lv.setAdapter(adapter);
}
}

Can't understand what the problem is, please tell me. (In android and java was just starting to understand).
April 4th 20 at 00:38
1 answer
April 4th 20 at 00:40
Solution
You list is not initialized. Before you list.add("Dima"); write list = new ArrayList()
thanks, did not notice - earl_Greenholt80 commented on April 4th 20 at 00:43

Find more questions by tags JavaAndroid