Answers for "what is comparable interface"

3

comparable interfacee

class Student implements Comparable<Student>{  
int rollno;  
String name;  
int age;  
Student(int rollno,String name,int age){  
this.rollno=rollno;  
this.name=name;  
this.age=age;  
}  
  
public int compareTo(Student st){  
if(age==st.age)  
return 0;  
else if(age>st.age)  
return 1;  
else  
return -1;  
}  
}
Posted by: Guest on July-06-2020

Code answers related to "what is comparable interface"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language