Strange Java Coding??? Class in class???

Posted by poeschlorn on Stack Overflow See other posts from Stack Overflow or by poeschlorn
Published on 2010-04-16T10:51:44Z Indexed on 2010/04/16 11:03 UTC
Read the original article Hit count: 243

Filed under:
|
|
|
|

Hi guys, I got a question about Java coding in general...

In some sample codes there are methods and classes declared WITHIN other methods and/or classes....

I've never heard/red about this...what effect does this kind of programming have? Wouldn't it be better to write down classes in a seperate file and methods side by side and not within each other (like every book tells you)? What are the advantages and disadvantages of this kind of programming?

Here's an example of what I mean:

Handler mHandler = new Handler() {
    public void handleMessage(android.os.Message msg) {
        TextView textView = (TextView) findViewById(R.id.description);
        textView.setText(mRoad.mName + " " + mRoad.mDescription);
        MapOverlay mapOverlay = new MapOverlay(mRoad, mapView);
        List<Overlay> listOfOverlays = mapView.getOverlays();
        listOfOverlays.clear();
        listOfOverlays.add(mapOverlay);
        mapView.invalidate();
    };
};

© Stack Overflow or respective owner

Related posts about java

Related posts about oop