如何解决此问题?问题在代码中写为注释 //这是java代码 //这是说comparable是原始类型,引用泛型类型comparable 应该参数化。我以前从未遇到过这个错误,所以我 不知道如何解决这个问题。 软件包edu.swosu.wordcraft.timers; /**计时器事件的基类(和抽象类)*/ 公共抽象类事件实现了可比较的{ 保护时间长; 保护长延时; /**构造新的计时器。 *这将确定当前系统时间并添加适当的 基于延迟参数的时间。 * *请注意,这不会自动将自身添加到计时器线程 * *@定时事件的参数延迟(毫秒) */ 公共活动(长时间延迟){ 时间=系统.currentTimeMillis()+延迟; 延迟=延迟; } /**实现可比较接口-比较时间参数的值 * */ 公共整数比较(对象其他事件){ 如果(!(事件的其他事件实例)){ //这真的不应该发生 抛出新的ClassCastException(“偶数比较期间对象无效”); } long otherTime=((事件)otherEvent.getTime(); 如果(this.time>otherTime){ 返回1; } 否则{ if(this.time

如何解决此问题?问题在代码中写为注释 //这是java代码 //这是说comparable是原始类型,引用泛型类型comparable 应该参数化。我以前从未遇到过这个错误,所以我 不知道如何解决这个问题。 软件包edu.swosu.wordcraft.timers; /**计时器事件的基类(和抽象类)*/ 公共抽象类事件实现了可比较的{ 保护时间长; 保护长延时; /**构造新的计时器。 *这将确定当前系统时间并添加适当的 基于延迟参数的时间。 * *请注意,这不会自动将自身添加到计时器线程 * *@定时事件的参数延迟(毫秒) */ 公共活动(长时间延迟){ 时间=系统.currentTimeMillis()+延迟; 延迟=延迟; } /**实现可比较接口-比较时间参数的值 * */ 公共整数比较(对象其他事件){ 如果(!(事件的其他事件实例)){ //这真的不应该发生 抛出新的ClassCastException(“偶数比较期间对象无效”); } long otherTime=((事件)otherEvent.getTime(); 如果(this.time>otherTime){ 返回1; } 否则{ if(this.time,java,Java,基本上,它会通知您,您必须提供实现Compariable的类可以与之进行比较的类。在您的情况下,如果要将事件与事件进行比较,只需编写 // This is java code // it is saying comparable is a raw type, references to generic type comparable <T> should be parameterized. I have never recieved this error before so

基本上,它会通知您,您必须提供实现
Compariable
的类可以与之进行比较的类。在您的情况下,如果要将
事件
事件
进行比较,只需编写

// This is java code 
//  it is saying comparable is a raw type, references to generic type comparable 
  <T> should be parameterized. I have never recieved this error before so I    
   don't know how to resolve the issue.  



package edu.swosu.wordcraft.timers;


    /** The base (and abstract) class for timer events */
    public abstract class Event implements Comparable {
protected long time;
 protected long delay;

/** Constructs new timer.  
 * This determines current system time and adds the appropriate 
       time based on the delay parameter. 
 * 
 * Note that this does not automatically add itself to the timer thread
 * 
 * @param delay     Delay for the timed event (in milliseconds) 
 */
public Event(long delay) {
    time = System.currentTimeMillis() + delay;
    this.delay = delay;
}

/** Implements Comparable interface - compares value of time parameter 
 * 
 */
public int compareTo(Object otherEvent) {
    if(!(otherEvent instanceof Event)) {
        //this really shouldn't happen
        throw new ClassCastException("Invalid Onject during Even compare");
    }

    long otherTime = ((Event)otherEvent).getTime(); 

    if (this.time > otherTime) {
        return 1;
    }
    else {
        if (this.time < otherTime) {
            return -1;
        }
        else {
            return 0;
        }
    }
}

public long getTime() {
    return time;
}

/** method to be called when timer fires
 *  
 */

public abstract void execute();
  }
实现可比较的

对不起,不是有意的:-)如果我通过该行进行此更改。public int compareTo(Object otherEvent)将出现错误。
implements Comparable<Event>