जावा संग्रह में addAll (..) विधि के लिए सही प्रकार का तर्क क्या है? अगर मैं ऐसा कुछ करता हूं:जावा जेनेरिक और ऐडअल विधि
List<? extends Map<String, Object[]>> currentList = new ArrayList<Map<String, Object[]>>();
Collection<HashMap<String, Object[]>> addAll = new ArrayList<HashMap<String, Object[]>>();
// add some hashmaps to the list..
currentList.addAll(addAll);
मुझे समझ में आता है कि मुझे दोनों चर शुरू करने की आवश्यकता है। हालांकि, मुझे संकलन त्रुटि मिलती है (ग्रहण से):
Multiple markers at this line
- The method addAll(Collection<? extends capture#1-of ? extends Map<String,Object[]>>) in the type List<capture#1-of ? extends Map<String,Object[]>> is not applicable for the arguments (List<capture#2-of ? extends
Map<String,Object[]>>)
- The method addAll(Collection<? extends capture#1-of ? extends Map<String,Object[]>>) in the type List<capture#1-of ? extends Map<String,Object[]>> is not applicable for the arguments
(Collection<HashMap<String,Object[]>>)
मैं क्या गलत कर रहा हूं?
क्या आप दोनों 'currentList' और 'newElements' दोनों के लिए अपनी घोषणाएं दिखाने के लिए संपादित कर सकते हैं? – elduff
मुझे लगता है कि 'newElements' को 'addAll' माना जाता है, मैंने कोड तय कर लिया है। – Jherico