Class IntervalComparator is public, should be declared in a file named IntervalComparator.java


  • 0
    X

    public class IntervalComparator implements Comparator<Interval>{
    public int compare(Interval l1,Interval l2){
    return l1.start-l2.start;
    }
    }

    why this class cannot be declared public?


  • 0
    H

    In java each public class should be declared in the respective file named same to the class name.


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.