Typical problem in java program ?
How to make this code compile ?
public class MinMax<N extends Number> {
public class N min,max;
public N getMin() { return min; }
public N getMax() { return max; }
public void add(N added) {
if(min == null || added.doubleValue()< min.doubleValue())
min = added;
if(max == null || added.doubleValue() < max.doubleValue())
max = added;
}
}
[422 byte] By [
Tatona] at [2007-10-3 3:04:51]

public class MinMax<N extends Number> {
public class N min,max;
public N getMin() { return min; }
public N getMax() { return max; }
public void add(N added) {
if(min == null || added.doubleValue()< min.doubleValue())
min = added;
if(max == null || added.doubleValue() < max.doubleValue())
max = added;
}
}
Tatona at 2007-7-14 20:54:55 >

public class MinMax<N extends Number> {
private N min,max;
public N getMin() { return min; }
public N getMax() { return max; }
public void add(N added) {
if(min == null || added.doubleValue()< min.doubleValue())
min = added;
if(max == null || added.doubleValue() < max.doubleValue())
max = added;
}
}
I am doing it.
Message was edited by:
Taton
Tatona at 2007-7-14 20:54:55 >

> public class MinMax<N extends Number> {
> private N min,max;
> public N getMin() { return min; }
> public N getMax() { return max; }
> public void add(N added) {
> if(min == null || added.doubleValue()<
> min.doubleValue())
> min = added;
> if(max == null || added.doubleValue() <
> max.doubleValue())
> max = added;
> }
> }
>
> I am doing it.
>
> Message was edited by:
> Taton
public class MinMax<N extends Number> {
private N min,max;
public N getMin() { return min; }
public N getMax() { return max; }
public void add(N added) {
if(min == null || added.doubleValue()< min.doubleValue())
min = added;
if(max == null || added.doubleValue() < max.doubleValue())
max = added;
}
public static void main(String[] args)
{
MinMax minmax = new MinMax();
minmax.add(8);
}
}
Done
Tatona at 2007-7-14 20:54:55 >

> > Done
>
> :-) Well done!
But there is a probs
output
D:\>javac MinMax.java
Note: MinMax.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
D:\>javac -Xlint MinMax.java
warning: [path] bad path element "%classpath%": no such file or directory
MinMax.java:14: warning: [unchecked] unchecked call to add(N) as a member of the
raw type MinMax
minmax.add(8);
^
2 warnings
Tatona at 2007-7-14 20:54:55 >
