2014-11-12 10 views
6

को बहिष्कृत किया गया है, मैं जावा में एक बहुआयामी सरणी से विस्तृत आउटपुट फ़ाइल प्राप्त करने की कोशिश कर रहा हूं। और मैंने वीका लाइब्रेरी आयात की, हालांकि मुझे एक त्रुटि मिली; The type FastVector<E> is deprecated.प्रकार फास्ट वेक्टर <E>

फास्ट वेक्टर के बजाय मैं क्या उपयोग कर सकता हूं और मैं नीचे दिए गए कोड को फिर से लिख सकता हूं?

import weka.core.FastVector; //Error: The type FastVector<E> is deprecated. 


    int [][] myArray = new int[45194][12541]; 

    for (int i = 0; i < myArray.length; i++) { 
     for (int j = 0; j < myArray[0].length; j++) { 
      System.out.print(myArray[i][j]+" "); 
     } 
     System.out.println(""); 
    } 

    int numAtts = myArray[0].length; 
    FastVector atts = new FastVector(numAtts); 
    for (int att = 0; att < numAtts; att++) { 
     atts.addElement(new Attribute("Attribute" + att, att)); 
    } 

    int numInstances = myArray.length; 
    Instances dataset = new Instances("Dataset", atts, numInstances); 
    for (int inst = 0; inst < numInstances; inst++) { 
     dataset.add(new Instance(1.0, myArray[inst])); //Error: Cannot instantiate the type Instance 
    } 

    BufferedWriter writer = new BufferedWriter(new FileWriter("test.arff")); 
    writer.write(dataset.toString()); 
    writer.flush(); 
    writer.close(); 

उत्तर

13

वीका अब टाइप किए गए ArrayLists अधिकांश स्थानों का उपयोग करता है। आप ArrayList<Attribute> का उपयोग कर सकते हैं:

ArrayList<Attribute> atts = new ArrayList<Attribute>(); 
    for (int att = 0; att < numAtts; att++) { 
     atts.add(new Attribute("Attribute" + att, att)); 
    } 
+2

हाँ, मुझे लगता है, लेकिन मैं उपरोक्त कोड में ArrayList का उपयोग कैसे कर सकता हूं? – EngineerEngin

+0

मैंने एक कोड स्निपेट के साथ अपनी प्रतिक्रिया संपादित की। यह आपके एटीएस चर के प्रकार को बदलने के रूप में सरल होना चाहिए। – Chris

+0

धन्यवाद, यह काम करता है। फास्ट वेक्टर त्रुटि चली गई है। – EngineerEngin

संबंधित मुद्दे