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 Java Data Structures Getting There Packages

Przemyslaw Mazur
PLUS
Przemyslaw Mazur
Courses Plus Student 9,296 Points

Does the main function reaches out for the first string in the code block if non is passed?

As above :)

2 Answers

What do you mean? If the public static void main still runs if nothing is passed into the String array typically named args?

Przemyslaw Mazur
Przemyslaw Mazur
Courses Plus Student 9,296 Points

Yes that's my question exacly. Sorry for not being precise enough,

Yes, say you just do the basic:

System.out.println("Hello world");

When you compile and run your program you will not send anything into the args and yet the Hello world will be printed. If you would want to get something from args then you could type the following:

System.out.println(args[0]);

and run your program passing the String into it, with something like:

java Application "Hello world"