Cannot resolve symbol 'println'

package org.example;
import java.util.*;

public class ListExamples {
List<String> names = Arrays.asList("Hi", "Dude","Wow");
System.out.println(names);
}
package org.example;
import java.util.*;

public class ListExamples {
List<String> names = Arrays.asList("Hi", "Dude","Wow");
System.out.println(names);
}
I got this error when I try to print: Cannot resolve symbol 'println' What? I never seen that error before. Its a simple print statement?
4 Replies
JavaBot
JavaBot10mo ago
This post has been reserved for your question.
Hey @Steadhaven! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
Steadhaven
SteadhavenOP10mo ago
We can only print inside methods and not classes? can someone explain that to me, because I don't seem to understand why that is the case.
Unknown User
Unknown User10mo ago
Message Not Public
Sign In & Join Server To View
JavaBot
JavaBot10mo ago
Post Closed
This post has been closed by <@305362010374406144>.

Did you find this page helpful?