Wow, what kind of code is that anyway? There's clearly something going on in it that wasn't there in theory. Don't worry, there is no need to try to understand this code for now. In this task, you only need to determine the types of variables used in this program based on the values assigned to them.
Types and variables
Code reviewing
Report a typo
Fill in the gaps with the relevant elements
public class Main {
public static void main(String[] args) {
haystack = "supercalifragilisticexpialidocious";
haystackLength = 34;
pattern = "cali";
patternLength = 4;
next;
for (int i = 0; i < haystackLength - patternLength + 1; i++) {
next = false;
for (int j = 0; j < patternLength; j++) {
if (haystack.charAt(i + j) != pattern.charAt(j)) {
next = true;
break;
}
}
if (!next) {
System.out.println("Pattern " + pattern + " found in " + haystack);
break;
}
}
}
}Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.