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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
This should work,
public class MyRectangle<T> {
T l, r, t, b;
}
public class MyRectangle<T> {
T l, r, t, b;
}
ASKER
Thanks