HashMap<Int, String> - Er findet die Int-Klasse nicht.

HPL

Aktives Mitglied
Java:
import java.io.*;
import java.util.*;
import java.util.regex.*;

public class Nergal{

public static void main(String[] args){


String[] dateien = new String[3];
dateien[0] = "gesamt.txt";
dateien[1] = "worm.txt";
dateien[2] = "raven.txt";


for(int i=0; i<dateien.length;i++){

int textnummer = 1;
String holla = null;

HashMap<Int, String> hm = new HashMap<Int, String>();

try{
        FileReader fr = new FileReader(dateien[i]);
        BufferedReader br = new BufferedReader(fr);
        String einzel = br.readLine();
        while ( einzel != null ){
        einzel = br.readLine();
        holla+=einzel;
        }
        br.close();
        } catch ( IOException e  ){
        e.printStackTrace();
}




for(int c = 0; c<(holla.length()-1);c++){
if(holla.substring(c, (c+1)) == holla.substring((c+1), (c+2))  ){

String x = " ";
x+=holla.substring((c+1),(c+2));
hm.put(textnummer, x);

}
}


textnummer++;


}


}
}

Problem:

Ich habe einen Array mit Dateinamen. Ich will hintereinander alle drei .txt-Dateien auslesen und die Substantive (i. e. Wörter mit großem Anfangsbuchstaben) herauspicken. Für jeden der drei Texte (jede Textdatei ist ein Text) will ich eine HashMap<Int, String> erzeugen, wobei der Int die Nummer des Textes ist, im String sind dann alle Substantive jeweils durch Leerzeichen getrennt.

Die Fehlermeldung lautet aber:
cannot find symbol
symbol: class Int
location: class Nergal
HashMap<Int, String> hm = new HashMap<Int, String>();

Ich habe schon einiges versucht, um das Problem zu lösen.

Frage:

Woran liegt die Fehlermeldung?
 
Code:
HashMap<Integer, String> hm = new HashMap<Integer, String>();

So dürfte es richtig sein 😉
 

Zurück
Oben