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
markhsia
2,139 Points00PS. Forgot how to make a parameter!
String, int, what?
1 Answer
Derek Markman
16,291 PointsYou question is pretty broad, but to create a simple String and int variable you would do:
String stringVariable = "blah";
int intVariable = 5;
Make sure you add the semi-colon at the end of the variable.
markhsia
2,139 Pointsmarkhsia
2,139 PointsSorry, wrote my question wrong though.
Derek Markman
16,291 PointsDerek Markman
16,291 PointsSorry it's taken me so long to respond, I often get very busy with other coding projects and forget to check the forums for replies.
If you're looking on how to add a parameter to your method, I can show you a quick example.
ArgumentExamples.java
OUTPUT
In this example, my Test() method takes a String parameter, and then prints it out to the screen, and my second method Test2() takes an int as a parameter and prints it out to the screen. The arguments that I am passing into these 2 methods are the variables "strArgument" and "intArgument".
I hope this helps you out, if you're still confused I can try to re-explain a different way.