Skip to main content

OpenJDK: Partial Classes in Java?

Posted by aschunkjava on November 8, 2007 at 5:40 AM PST

OpenJDK: Partial classes in Java

While i was working on a Visual C# project build with Visual C# Express 2005 i was flying over the C# syntax features. One interesting thing is the possibility to define so called partial classes that is a class definition that is distributed over several sources files. Yes you are reading right, source files.

Microsoft did introduce this to make distributed team developed more easier by allowing distributed teams to work on the same class yet with their own defintions. The complete class will be generated when the appliction is compiled.

To understand what this means lets look at this code:

public partial class EmployeeA{

public partial class EmployeeB{

Now image that the class EmployeeA is developed by team A and class EmployeeB is developed by team B. They can use this is as their basis for work and then merge these two distinct classes into one class called Employee when compiling the app.

I dont know how hard it is to implement something in Java but i think its a nice feature also if have GUI apps for example. The Visual C# designer makes huge use of this so you will always find partial classes when working with Visual C#.

Decimal data type

Another interesting thing is that C# has a decimal data type to define decimal values i.g. for currencies. In Java you have to use the Locale class for this.