0

What's the impact when list is final.?

What happen when we declare list as final as below final List <String> list=new ArrayList();

25th May 2019, 3:13 AM
Mintu Sharma
Mintu Sharma - avatar
1 Antwort
+ 15
Nothing was happen but if you add another memory address in (list) variable than compiler throw error becz the variable (list) is final and you cant assign another memory address in list veriable Example This code run without any error ArrayList<Integer> obj = new ArrayList<>(); // add an another memory address obj = new ArrayList<Integer>(); Compiler error final ArrayList<Integer> obj = new ArrayList<>(); // add an another memory address obj = new ArrayList<Integer>();
26th May 2019, 9:25 AM
Sumit Programmer😎😎
Sumit Programmer😎😎 - avatar