Results 1 to 3 of 3
Thread: Java language question
- 05-07-2012, 09:44 PM #1
Member
- Join Date
- May 2012
- Posts
- 4
- Rep Power
- 0
Java language question
Hello, I have a question about an example given at: Service | Android Developers
I don't think you need to know anything about Android to be able to answer this question.
What the heck is going on here? I've never seen syntax like this before, but nowadays I see it all the time in Android examples.
It looks like a new ServiceConnection is being made, but then, instead of ending with a semicolon, we've got braces and then 2 function definitions (overriding the 2 abstract ServiceConnection functions) This must be some special feature of Java I've never seen before, can someone tell me what this feature is called so I can read more about it? I know you can't do this in C++.
Java Code:private LocalService mBoundService; private ServiceConnection mConnection = new ServiceConnection() { public void onServiceConnected(ComponentName className, IBinder service) { ...... ....... } public void onServiceDisconnected(ComponentName className) { ...... } };Last edited by EGD Eric; 05-07-2012 at 10:06 PM.
- 05-07-2012, 10:12 PM #2
Re: Java language question
Not advanced, not Java. Moved from Advanced Java.
Ever heard of anonymous inner classes?
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 05-07-2012, 10:26 PM #3
Member
- Join Date
- May 2012
- Posts
- 4
- Rep Power
- 0
Similar Threads
-
Change language in java
By shomid in forum AWT / SwingReplies: 3Last Post: 04-23-2012, 11:20 PM -
Is java a top language to learn?
By insanepenguin in forum New To JavaReplies: 26Last Post: 01-24-2010, 10:16 PM -
Java is an OOP language.
By mysourha in forum New To JavaReplies: 3Last Post: 01-14-2010, 10:15 AM -
Is JAVA the right language?
By EDENO in forum New To JavaReplies: 3Last Post: 08-08-2008, 12:29 AM -
Question about java object oriented Language
By lenny in forum New To JavaReplies: 3Last Post: 07-26-2007, 03:59 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks