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

Arjun Vemperala
Arjun Vemperala
1,212 Points

can any one explain the importance of static void in this code public static void main(String[] args){ }

can any one explain the importance of static void in this code public static void main(String[] args){ } code taken from creating classes in java objects

1 Answer

Simon Coates
Simon Coates
28,694 Points

public static void main(String[] args) is typically how you run a Java program. (there are similarly named methods in other c-family languages). The essential information is that java and IDE's know to look for this method (with that precise name/signature). To break it down further, it's public - hence is accessible. It's static - hence doesn't require any existing object to run. And it has a String[] parameter to accept arguments from the command line. And void means it doesn't need to return any value.