When I executed the following code using the built-in Groovy tool in IntelliJ IDEA, an error occurred.
StringBuilder sb = new StringBuilder()
String a = "abc"
String b = "123"
for (int i = 0, j = 0; i < a.length() || j < b.length(); i++, j++) {
if (i < a.size()) {
print(a[i])
sb.append(a[i])
}
}
print(sb)
Error is as follows
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
ideaGroovyConsole.groovy: 8: unexpected token: = @ line 8, column 12.
for (int i = 0, j = 0; i < a.length() || j < b.length(); i++, j++) {
^
1 error
at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:310)
at org.codehaus.groovy.control.ErrorCollector.addFatalError(ErrorCollector.java:150)
at org.codehaus.groovy.control.ErrorCollector.addError(ErrorCollector.java:120)
for (int i = 0, j = 0; i < a.length() || j < b.length(); i++, j++) {
My guess is that the grammar problems, but didn't send any questions。