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

Android Build a Simple Android App (retired 2014) Getting Started with Android Java Variables Explained

I am having trouble putting in place the variables, does anyone have any tips.

Need little more details on how to understand the variables and how to connect them properly.

1 Answer

Harry James
Harry James
14,780 Points

Sure thing. In Java we make variables like this:

[Type] [Name] = ...;

For example, let's say I want to make favouriteNumber equal to 10. I'd write this:

int favouriteNumber = 10;

(int = Integer which is just another word for number).

Or a piece of text:

String welcomePhrase = "Hello";

When you do more advanced variables, you'll learn about public, protected and private, final, static and void keywords. All do different things. Public, protected and private declare where the variable can be used (See http://gyazo.com/8b8381a173f6d11b96884a912e3579f6 for more details) whereas final, static and void mean different things too (final means can't change, static means that only one instance of the variable can exist and void means does not return anything). There are other keywords I haven't mentioned here but, these are probably the main ones you'll come across during these courses.

Hope it helps!

Thank you!