Java: 2-assignments-2-initializations inside for-loop not allowed?
- by HH
$ javac MatchTest.java
MatchTest.java:7: ')' expected
for((int i=-1 && String match="hello"); (i=text.indexOf(match)+1);)
^
MatchTest.java:7: ';' expected
for((int i=-1 && String match="hello"); (i=text.indexOf(match)+1);)
^
MatchTest.java:7: ';' expected
for((int i=-1 && String match="hello"); (i=text.indexOf(match)+1);)
^
MatchTest.java:7: not a statement
for((int i=-1 && String match="hello"); (i=text.indexOf(match)+1);)
^
MatchTest.java:7: illegal start of expression
for((int i=-1 && String match="hello"); (i=text.indexOf(match)+1);)
^
5 errors
$ cat MatchTest.java
import java.util.*;
import java.io.*;
public class MatchTest {
public static void main(String[] args){
String text = "hello0123456789hello0123456789hello1234567890hello3423243423232";
for((int i=-1 && String match="hello"); (i=text.indexOf(match)+1);)
System.out.println(i);
}
}