• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Help for a beginner

JUSDroid

Lurker
Jul 1, 2012
1
0
Greetings all.

Just looking for a bit of a lifeline. I am new to both Android and Java, so please excuse my green-ness :eek:

While reading through the API guides and various developer tutorials, I came across the following jargon in variable declarations:


EditText editText = (EditText) findViewById(R.id.edit_message);

so, I understand that in this we are creating a new object of type EditText called editText. Curious about the (EditText) in brackets after the = sign. What does this mean? Does this mean that we are creating a new instance? Are we only creating an empty variable, or is it simply a reference to the previously existing EditText object returned by findViewById?

How would this differe from :
EditText editText = findViewById(R.id.edit_message);

I am not looking for a lesson on Java here, but just a quick explaination of what the extra bracketed variable type is doing, and perhaps a link to a tutoral website that explains this jargon usage in more detail.

Any help is greatly appreciated.

Regards,
JUS.
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones