Auf Thema antworten

Hallo ich weiß nicht so recht wie ich von einem String in einen Vektor schreiben kann. Das ist der bisherige Code:


[code=Java]public Vector<N> getShortestPath(N location1, N location2) {


            Vector<String> vecPath;

            int Loc1;

            int Loc2;

           

            String[] strLocations = (String[])vecLocations.toArray(new String[vecLocations.size()]);

           

            if ((location1 != null) && (location2 != null)){

               

                Loc1 = getLocationIndex(location1);

                Loc2 = getLocationIndex(location2);

               

                if ((Loc1 != -1) && (Loc2 != -1) && (Loc1 != Loc2)) {

                   

                    vecPath = new Vector<String>();

                   

                    do {

                        vecPath.add(0, strLocations[Loc2]);

                        Loc2 = intMatrixT[Loc1][Loc2];

                    } while (Loc2 != Loc1);

                   

                    vecPath.add(0, strLocations[Loc1]);

                   

                                   

                   

                    return vecPath;

                       

                    }

                }       

        return null;

    }

[/code]



Ich habe ja anfangs einen Vektor mit Strings (vecPath). Die Methode an sich ist aber vom Typ <N> also schmeißt er mir einen Fehler beim return am Ende mit dem vecPath, da dieser vom Typ String ist, aber er möchte ihn in N wieder haben.


 Weiß einer vllt eine Idee was ich da machen kann?


Ich bitte um euren Rat. Vielen Dank im vorraus!



Oben