August 22, 2008 Re: Object Oriented Programming with D Language. Private access specifier. | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Jacob Carlborg | Jacob Carlborg wrote:
> In Java you can have several classes in the same file and they have access to each others private members, it's called inner classes. It's useful for listeners for example.
Java requires you to use classes for anything that has structure or anything that can do anything. You can't have two top-level classes in one file, though; you need another class to act as a namespace for them.
And using inner classes for events is ugly. I implemented an event broker in Java, but I couldn't stand using it because I had to use inner classes to get anything done.
| |||
August 25, 2008 Re: Object Oriented Programming with D Language. Private access specifier. | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Christopher Wright | Christopher Wright wrote: > You can't have two top-level classes in one file, though; you need another class to act as a namespace for them. > Surprisingly, you can have more than one top-level class in a Java file. But only one can be public, the others have default protection, and are not accessible from outside the file. (I've only found this out recently, some months ago, even though I've programming in Java for quite longer) -- Bruno Medeiros - Software Developer, MSc. in CS/E graduate http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D | |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply