Results 1 to 3 of 3
  1. #1
    EGD Eric is offline Member
    Join Date
    May 2012
    Posts
    4
    Rep Power
    0

    Default 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.

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,197
    Rep Power
    19

    Default Re: Java language question

    Not advanced, not Java. Moved from Advanced Java.

    Ever heard of anonymous inner classes?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    EGD Eric is offline Member
    Join Date
    May 2012
    Posts
    4
    Rep Power
    0

    Default Re: Java language question

    Nope, but thanks for naming it for me.

Similar Threads

  1. Change language in java
    By shomid in forum AWT / Swing
    Replies: 3
    Last Post: 04-23-2012, 11:20 PM
  2. Is java a top language to learn?
    By insanepenguin in forum New To Java
    Replies: 26
    Last Post: 01-24-2010, 10:16 PM
  3. Java is an OOP language.
    By mysourha in forum New To Java
    Replies: 3
    Last Post: 01-14-2010, 10:15 AM
  4. Is JAVA the right language?
    By EDENO in forum New To Java
    Replies: 3
    Last Post: 08-08-2008, 12:29 AM
  5. Question about java object oriented Language
    By lenny in forum New To Java
    Replies: 3
    Last Post: 07-26-2007, 03:59 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •