If you use 1st way, you can change the implementation later easily. For example: You need to change your implementation from ArrayList to LinkedList, you can simply change implementation, you don’t need to worry about making changes to all the code where variable list is being used.
You won’t be able to do it in case of 2nd way.It is always a good idea to code to an interface rather than concrete implementation. List vs ArrayListLet’s see tabular difference between List and ArrayList in java.