Android Programming and Java syntax
===

This is my first post so please be gentle.

It's a question regarding the syntax used in Eclipse SDK while programming some JAVA code for an Android App.

I am an embedded microcontroller engineer that's mainly used to programming in Assembler (a long time ago) and C. I am a newbie when it comes C++ and JAVA and to help me write my code I have been using a mix of the developer.android.com for background info and stackoverflow.com for real world examples and have found them very useful.

So, I have no problem writing code to do what I want to do because I've always done it, but I am finding it very difficult getting my head around the syntax used in writing Android Apps.

For example to access the GPS one of my lines of code read thus:-

LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);

but can be shortened to this:-

locationManager = (LocationManager)getSystemService(LOCATION_SERVICE);

I prefer the second version, but why were some examples written like the first example? Both seem to work fine. I've seen other examples that look even more complicated using "Class".

Secondly, is this not a complicated way to do a really simple thing:-

Toast.makeText(getBaseContext(),"Hello World",Toast.LENGTH_SHORT).show();

Why not:-

Toast("Hello world");

It now takes me four times as long as it use to write code.

Many thanks for reading my post if you got this far.

Andrew
