User Profile

Collapse

Profile Sidebar

Collapse
authorityaction
authorityaction
Last Activity: Mar 18 '08, 06:28 AM
Joined: Feb 4 '08
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • authorityaction
    replied to compareTo Help
    in Java
    Thank you Laharl! Casting to the correct object did the trick.
    See more | Go to post

    Leave a comment:


  • authorityaction
    replied to compareTo Help
    in Java
    I had this thought earlier as well. When I change it, I get this error:

    [code=java]Polynomial.java :28: Polynomial.Term is not abstract and does not override abstract method compareTo(java. lang.Object) in java.lang.Compa rable
    private class Term implements Comparable[/code]

    Also, I don't know if it will make a difference but for the assignment I had to make Term as an inner class of Polynomial. All of the previous...
    See more | Go to post

    Leave a comment:


  • authorityaction
    started a topic compareTo Help
    in Java

    compareTo Help

    I am writing a polynomial class that later I will use to add two polynomials together. Right now I am working on writing the compareTo method (my class implements Comparable). Unfortunately I am getting the following error:

    [CODE=JAVA]Polynomial.java :79: cannot find symbol
    symbol : variable degree
    location: class java.lang.Objec t
    if (this.degree == ob1.degree)
    ...
    See more | Go to post

  • authorityaction
    replied to Generics Help
    in Java
    Thanks for that code! I changed to the following and everything worked.

    [code=java]public static <T extends Number> double standardDeviati on(ArrayList<T> a)

    private static <T extends Number> double calcAverage(Arr ayList<T> a)[/code]
    See more | Go to post

    Leave a comment:


  • authorityaction
    replied to Generics Help
    in Java
    If I change it to static I get the following error:

    [code=java]MyStatisticsCla ss.java:37: non-static class T cannot be referenced from a static context
    public static double standardDeviati on(ArrayList<T> a)[/code]...
    See more | Go to post

    Leave a comment:


  • authorityaction
    started a topic Generics Help
    in Java

    Generics Help

    I am working on an assignment to write a generic class called MyStatisticsCla ss with type parameter T where T is a numeric object. with a method called standardDeviati on that takes a ArrayList of type T and returns a double. I am getting the following error when I try to compile:

    [code=java]MyStatisticsCla ss.java:27: standardDeviati on(java.util.Ar rayList<T>) in MyStatisticsCla ss<T> cannot be applied to (java.util.Arra yList<java.lang .Double>)...
    See more | Go to post
No activity results to display
Show More
Working...