There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply () below.
If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.
Join the Discussion. Help a fellow learner on their journey.
Ask or answer a question about this exercise by clicking reply () below!
You can also find further discussion and get answers to your questions over in Language Help.
Agree with a comment or answer? Like () to up-vote the contribution!
I cannot seem to get my practice code to run. I have multiple print statements in main, but when I type java List in the terminal, I get nothing. Am I missing something?
How do I replace that terminal on the right, which doesn’t work, with an IntelliJ IDEA window? I can’t test the code. javac List.class returns an error:
javac: invalid flag: List.class
Usage: javac
use --help for a list of possible options
Why do I have to create arrayLists inside main methods? You usually declare and initialize things before main methods (for example, constructor methods typically precede them). However, if I create an arrayList before my main method, the code doesn’t work. Why?
UPD: I discovered it has to do with static/non-static qualities (though, if you feel like explaining it to me in more detail, I would appreciate it as I don’t fully get it!). Unfortunately, I forgot what static/non-static means. To add insult to injury, I don’t remember which previous lesson mentioned it, and it’s very inconvenient to search for information in a course on Codecademy! You can’t even preview “sub-lessons” of each lesson. Basically, you have to do your search manually. It’s a pitty!
UPD2: It would be nice if Codecademy stressed the fact that arrays must be created inside main methods. Could you consider including that information in the lessons? I may be not the last person who is confused by that
// You wrote:
class List {
public static void main(String[] args) {
...
System.out.println(detectives.indexOf("Fletcher"));
}
System.out.println(detectives.size());
System.out.println(detectives.get(1));
}
// It should be:
class List {
public static void main(String[] args) {
...
System.out.println(detectives.indexOf("Fletcher"));
System.out.println(detectives.size());
System.out.println(detectives.get(1));
}
}