compilation avec un String
Bonsoir,
Je n'arrive pas à trouver ces 3 erreurs de compil; si quelqu'un pouvait m'aider
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
class exo103 {
static boolean egalite (String t, String s) {
boolean res = false;
for (int i=0; i<t.length; i++){
if (t.length == s.length) && (t.charAt(i) == (s.charAt(i))){
boolean res = true;
}else{
boolean res = false;
}
}
return res;
}
public static void main (String [] args) {
String s1 = "minci";
String t1 = "mince";
Terminal.ecrireInt ( s1.compareTo(t1));
Terminal.ecrireStringln( " " + s1.equals(t1));
}
} |
le compilateur m'indique :
C:\Documents and Settings\rohmer>javac "C:\Documents and Settings\rohmer\exo103
java"
C:\Documents and Settings\rohmer\exo103.java:5: illegal start of expression
if (t.length == s.length) && (t.charAt(i) == (s.charAt(i))){
^
C:\Documents and Settings\rohmer\exo103.java:5: ';' expected
if (t.length == s.length) && (t.charAt(i) == (s.charAt(i))){
^
C:\Documents and Settings\rohmer\exo103.java:7: 'else' without 'if'
}else{
^
3 errors
merci