1. Download our Official Android App: Forums for Android!

Apps nested class declarations?

Discussion in 'Android Development' started by mrqs, Mar 2, 2010.

  1. mrqs

    mrqs Android Expert
    Thread Starter
    Rank:
    None
    Points:
    128
    Posts:
    1,446
    Joined:
    Sep 28, 2009

    i'm coming from a mainly c++/c# background and haven't done much with java, so this is something that caught my eye when looking at some simple examples of android code

    Code (Text):
    1. class GameView extends SurfaceView implements SurfaceHolder.Callback {
    2.     [COLOR="Red"]class GameThread extends Thread {
    3.         [...]
    4.     }[/COLOR]
    5.     private GameThread thread;
    6. [...]
    7. }
    this to my eyes is absolutely hideous and i'm wondering if you actually have to do it like this or if you can just make GameThread its own .java file and import that (moving the red part to a different file) ?

    if it has to be done like this, why?
    and if not, why would you?
     

    Advertisement

  2. alostpacket

    alostpacket Over Macho Grande?
    Rank:
    None
    Points:
    513
    Posts:
    7,973
    Joined:
    Nov 29, 2009

    Nov 29, 2009
    7,973
    3,603
    513
    Android App Developer
    NY
    You can make it it's own class for sure, but I agree it's one of the most idiotic aspects of java.

    When I see anonymous callbacks or inner classes in a modern, strongly typed OOP language I wanna smack someone upside the head with a wet fish.

    Just wait until you see the SDK ;)
     
    mrqs likes this.

Share This Page

Loading...