Link to home
Start Free TrialLog in
Avatar of DJ_AM_Juicebox
DJ_AM_Juicebox

asked on

A templated rectangle

Hi,
I have a rectangle class like:

public class MyRectangle
{
     int l, r, t, b;
}

because using the built in java one has doubles for the members instead of int and its really annoying to use with graphics drawing. How can I update it to just 'template' the type, something like:

public class MyRect<int>
{
     int l, r, t, b;
}
public class MyRect<double>
{
    double l, r, t, b;
}

etc?

Thanks
ASKER CERTIFIED SOLUTION
Avatar of CPColin
CPColin
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of DJ_AM_Juicebox
DJ_AM_Juicebox

ASKER

ah ok i was importing some other one using double as the type, this should be fine,

Thanks
This should work,
 
 
public class MyRectangle<T> {
  T l, r, t, b;
}