How do I initialise an arrayList for fixed size and assign it to nil?
I have code as below in Swift/IoS.
What is the equivalent in Java for below code in Java?
var studentsList:[Result?] = [Result?](repeating: nil, count: 5) //assign to nil
studentsList[2] = newStudent //assign at different level Eg:2
studentsList = studentsList.filter { $0 != nil } //filter all the nil objects
I need an array for fixed length.
I am able to add the elements in the order, but I need the ability to add the element at any of the initialised levels.
For example, if I fix the size of array as 5, I should be able to assign object to arrList[2] even though arrList[0] and arrList[1] are still nil