Hallo,
ich habe folgenen java code erstellt
an der stelle return z;
gibt er mir die meldung: type mismatch:cannot covert from int to string
Die Fehlermeldung in der Console lautet:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
Type mismatch: cannot convert from int to String
at aufgabe1.Aufgabe4.count(Aufgabe4.java:23)
at aufgabe1.Aufgabe4.main(Aufgabe4.java:11)
Kann mir jemand helfen weiß nicht warum das so nicht geht.
MFG
ich habe folgenen java code erstellt
Java:
package aufgabe1;
public class Aufgabe4 {
/**
* @param args
*/
public static void main(String[] args) {
String s="atgatccttaacggtaataaata";
String v="gat";
String result = count(s, v);
System.out.print(result);
}
public static String count(String a, String b)
{
String t;
int z=0, i, k=a.length(),l=b.length();
for (i=0; i<=k-l; i=i+1)
t=a.substring(i,i+l);
if (t.equals(b))
z=z+1;
return z;
}
}
an der stelle return z;
gibt er mir die meldung: type mismatch:cannot covert from int to string
Die Fehlermeldung in der Console lautet:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
Type mismatch: cannot convert from int to String
at aufgabe1.Aufgabe4.count(Aufgabe4.java:23)
at aufgabe1.Aufgabe4.main(Aufgabe4.java:11)
Kann mir jemand helfen weiß nicht warum das so nicht geht.
MFG
Zuletzt bearbeitet: