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 trialPrzemyslaw Mazur
Courses Plus Student 9,296 PointsDoes the main function reaches out for the first string in the code block if non is passed?
As above :)
2 Answers
Pedro Cabral
33,586 PointsWhat do you mean? If the public static void main still runs if nothing is passed into the String array typically named args?
Przemyslaw Mazur
Courses Plus Student 9,296 PointsThanks a lot, make sense.
Przemyslaw Mazur
Courses Plus Student 9,296 PointsPrzemyslaw Mazur
Courses Plus Student 9,296 PointsYes that's my question exacly. Sorry for not being precise enough,
Pedro Cabral
33,586 PointsPedro Cabral
33,586 PointsYes, 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"