프로그래밍/JAVA

[Java Error] java list add 시 null pointer exception

Gooding 2022. 11. 7. 20:36
728x90
반응형

java list add 시 null pointer excetpion

 

list 생성시

List<Long> longList = null;
longList.add(2L);

이렇게 작성하지 말고

 

List<Long> longList = new ArrayList<>();
longList.add(2L);

위와 같이 선언하기

반응형