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
Kaleb Burnham
4,877 PointsAre variables declared when a method with input parameters is created?
In the following method is the String variable "author" being declared within the parentheses?
public create(String author)
Further, is it being initialized when the method is called?
1 Answer
Simon Coates
28,695 Pointsit's a variable that makes a value passed into the method available within that function. But there is a complexity with pass by value. There's a complexity or two in terms of dealing with primitives vs object type with parameter. An object you get in, you can modify (excluding immutable object like strings). A primitive you get in will be a separate memory location to the value passed in. As such, an awareness of the lower level will help avoid disappearing changes and assist with knowing when you need to use a return value. If you're only using the passed in value, you probably don't need to worry about this stuff. yet.