FAQ: Java: Introduction to Classes - Classes: Syntax

This community-built FAQ covers the “Classes: Syntax” exercise from the lesson “Java: Introduction to Classes”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Learn Java

FAQs on the exercise Classes: Syntax

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 (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 (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

Ive gotten the second part of this wrong for simply not having a space between the closing bracket and args in the main method. In other words this will come back as incorrect because there it’s not (String args)

public class Store{
public static void main(Stringargs){

}
}

1 Like

yea bro same for me i wrote exactly as it shown

1 Like

So, beginner here, got stuck in this exercise, was asked to [In the code editor, create a public Store class.] but when I type code

public class Store {
// scope of Car class starts after curly brace
//I basically type on my own and try for three times, and on fourth attempts i copy the example
}

I gave above codes as answer and hit the blue-run-button, return a LOADING and this message [Error: Main method not found in class Store, please define the main method as:
public static void main(String args)
or a JavaFX application class must extend javafx.application.Application] so I was stuck.
What goes wrong? With my limited experience I think I did correctly created a public Store.class , any idea Senpai?

… should have a total of two sets of curly braces: one for the scope of the class, and one to define the scope of the main method. … needing a set of curly braces after public static void main(String args){
}

1 Like

has anyone found a fix for the second task?

nevermind i tried changing it to private static void main instead of public and it worked

I do not know what the error is, but here is the solution ctrl+c ctrl+v
public class Store {

public static void main(String args) {

}

}

If you guys are getting error for some reason even if you’re actually correct, you just have to add space right after the class Store and right after the before “args”.

1 Like

I was running into issues here as well and it ended up being so simple. I had a space where I shouldn’t have.

Thank you that space after the actually worked and it fixed itself.

Hey, I was struggling with trying to get it to work all night but when I woke up this morning I figured out that if you type in private instead of public it will respond with what you need to write in the output. I tried to just copy and paste what someone put earlier on in the thread and it did not work for me.
public class Store {

public static void main(String args) {

}

}

This is what I ended up with, so maybe one thing or the other will work for you.

In General there is a bug in the site if you can’t able to clear the excerise even though your have return a right answer, pls pls refresh the page.

Answer -
public class Store
{
public static void main(String args){}
}