Hi @ All...
Hab mal wieder nen Problem ???:L
und dort bekomm ich den Laufzeitfehler
PS C:\Users\Sduni\Documents\TU-Berlin Naturwissenschaften In der Informationsgesellschaft\09-10 WS\Meine Projecte\Permutation> java Permutation
java.exe : Exception in thread "main" java.lang.StackOverflowError
Bei Zeile:1 Zeichen:5
+ java <<<< Permutation
+ CategoryInfo : NotSpecified: (Exception in th...ckOverflowError:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
at java.util.LinkedList$Entry.<init>(Unknown Source)
at java.util.LinkedList.addBefore(Unknown Source)
at java.util.LinkedList.add(Unknown Source)
at Permutation.permute(Permutation.java:15)
at Permutation.permute(Permutation.java:27)
at Permutation.permute(Permutation.java:27)
at Permutation.permute(Permutation.java:27)
at Permutation.permute(Permutation.java:27)
at Permutation.permute(Permutation.java:27)
....
Warum dieses?
Hab mal wieder nen Problem ???:L
Java:
import java.util.*;
import java.util.LinkedList;
public class Permutation{
public List<String> liste = new LinkedList<String>();
public int a;
public void permute(int[] ar){
if(ar.length==0) return;
String str = "";
for(int i = 0; i < ar.length; i++){
str = str + ar[i];
}
liste.add(str);
//System.out.println(liste.get(0));
for(int i = 0; i < ar.length; i++){
ar[i] = a;
ar[i] = ar[ar.length-1];
ar[ar.length-1] = a;
String str2 = "";
for(int n = 0; n < ar.length; n++){
str2 = str2 + ar[i];
}
for(int j = 0; j < liste.size(); j++){
if(liste.get(i).equals(str2)) return;
else permute(ar);
}
}
}
public static void main(String[] args){
int[] array = {1,2,3};
Permutation perm = new Permutation();
perm.permute(array);
String out = "";
for(int i = 0; i < perm.liste.size(); i++){
out = out + " - " + perm.liste.get(i);
}
System.out.println(out);
}
}
und dort bekomm ich den Laufzeitfehler
PS C:\Users\Sduni\Documents\TU-Berlin Naturwissenschaften In der Informationsgesellschaft\09-10 WS\Meine Projecte\Permutation> java Permutation
java.exe : Exception in thread "main" java.lang.StackOverflowError
Bei Zeile:1 Zeichen:5
+ java <<<< Permutation
+ CategoryInfo : NotSpecified: (Exception in th...ckOverflowError:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
at java.util.LinkedList$Entry.<init>(Unknown Source)
at java.util.LinkedList.addBefore(Unknown Source)
at java.util.LinkedList.add(Unknown Source)
at Permutation.permute(Permutation.java:15)
at Permutation.permute(Permutation.java:27)
at Permutation.permute(Permutation.java:27)
at Permutation.permute(Permutation.java:27)
at Permutation.permute(Permutation.java:27)
at Permutation.permute(Permutation.java:27)
....
Warum dieses?
Zuletzt bearbeitet: