I have two Array list say currentTopicsDetailsList and updatedTopicsDetailsList. The Lists are of object Topic(class) i.e.,
List<Topic> currentTopicsDetailsList;
List<Topic> updatedTopicsDetailsList;
The class Topic has properties
- rank
- socialIndex
- twitterIndex
- newsIndex
I want to update the values in currentTopicsDetailsList with updatedTopicsDetailsList values
e.g. at
- currentTopicsDetailsList[4].rank=158
- currentTopicsDetailsList[4].socialIndex= +245
- currentTopicsDetailsList[4].twitterIndex=-345
currentTopicsDetailsList[4].newsIndex=+340
updatedTopicsDetailsLIst[4].rank=null
- updatedTopicsDetailsLIst[4].socialIndex= 300
- updatedTopicsDetailsLIst[4].twitterIndex=-56
- updatedTopicsDetailsLIst[4].newsIndex=+340
I want to overwrite the currentTopicsDetailsList[4] with updatedTopicsDetailsList[4] with a condition that whichever has null should be ignore i.e., rank property should be 158 eventhough its null in updatedTopicsDetailsList[4].rank
Right now am doing it with FOR loop index level comparison for null & empty strings, but is there a alternative and quick way of doing things.