Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

multiple classes in a single physical file on android

Right now I have to create a new physical file in eclipse android for every public class I create

For eg if I have the below 2 classes (System and Region) like this:

Region.java file:

package com.acrossair.tvguideuk;

public class Region
{
      public int RegionID;
      public String Name;
}

System.java file:

package com.acrossair.tvguideuk;

public class System
{
      public int SystemID;
      public String Name;
}

How can I simply create a file CustomObjects.java and have all of these custom classes in 1 single file?

like image 759
Raj Avatar asked Dec 22 '22 17:12

Raj


1 Answers

You could create your custom objects as public inner classes of a CustomObjects class:

public class CustomObjects {
  public class Region {
    public int RegionID;
    public String Name;
  }
  public class System {
    public int SystemID;
    public String Name;
  }
}

But you couldn't use static members in the inner classes unless they were static themselves.

like image 162
user634618 Avatar answered Jan 07 '23 12:01

user634618