Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java

One Main Method in Java

Hello everyone,

I have been doing great and learning a lot with the courses in Java. I just wanted to get an understanding of the main method. I have been reading that every application needs one main method. How does that work, and what needs to go in it?

1 Answer

hi Jonathan Bonilla ,

I don't know how knowledgeable you are in Java, so i'll try to keep it as basic as possibel :p

Every time you want to execute an application, it searches for the main method so it can execute the application.

The code that is put in the main method says to the application what to do. For example, you could have a bunch of classes with code in them. But if there isn't a main method where the code of these classes is used, nothing happens.