Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
Ben Morse6,068 Points
"Key" what does he mean?
When talking about the "key variable" when passing data through the intent method, I am still unclean about what "key" means. If you were to define it, how would you?
code: intent.putExtra("name", name);
Is "name" the declaring variable that is going to hold a value(name) as it is passed to to the next activity?
I believe he is referring to a key value pair. A key is an identifier, a value is a variable or some sort of data linked to that key.
Key1: Value1 Key2: Value2
By referencing Key1 we can get the value associated with it (Value1)
In this example:
The first part, "name" is the key.
The second part, name is a variable (a string in this case) which was defined earlier in the code.
This example may help.
I'm not great with Java so not sure of the syntax but the concept of key value pairs is the same in many different languages.
Hope this helps :)