Hello, I'm starting to learn java on the book Head First - Java. I understand that the question is probably childish, but this error takes off for me, and I don’t know what the problem is, like the brackets are arranged correctly, but it still flies, Please tell me.

public class MovieTestDrive { public static void main (String[] args) { Movie one = new Movie(); one.title = "Inception"; one.genre = "Army"; one.rating = 8; Movie two = new Movie(); two.title = "The race"; two.genre = "Arcade"; two.rating = 6; two.playIt } } class Movie { String title; String genre; int rating; void playIt() { System.out.println("Проигрывание Фильма"); } } 

    1 answer 1

    When calling, like when declaring a method , it is necessary to use brackets, even if the method does not accept any parameters. And after each operator must follow a semicolon.

    So instead

    two.playIt

    need to write

     two.playIt(); 
    • Yes, you are right that I missed it. Now changed, but still the same error. - Anton Barinov
    • @AntonBarinov code all led? - Anton Shchyrov
    • @AntonBarinov I have your code, after the fixes, it works - Anton Shchyrov
    • Thank you, sorted out - Anton Barinov