Can not run Classes or Methods

已回答

I just created a small project in IntelliJ. I created one class in the src package (FileFilter) but i can not run the method in this class by the run button, becaus it's simply not there. Only the build button is shown. 

So I created another class (Main), containing the main method and an empty void method. The class and the main method can be run, but the default method has the same issue I have with my FileFilter class. Also, i can not run one of the methods within the main file.

As you can see, the icon on the left of my FileFilter class doesn't have the green run symbol on it. I asked ChatGPT for help, but rebuilding the project wasn't a helpful solution. Any tips are appreciated. Thank you (and sorry for my English haha, I'm from Germany)

0

Yes I got that, but in my main class I can't run any other method I implemented, although both the classes and the methods are public.

0

Create an instance of your class in the main method to call its methods, like this:

public class Hello {
  public void printMe() {
    System.out.println("hello");
  }

  public static void main(String[] args){
    new Hello().printMe();
  }
}

 

Please use https://stackoverflow.com/ for your generic programming questions that are not specific to the IDE.

0

请先登录再写评论。