private class FileType extends Object {
private String Name;
private String Type;
public FileType() {
Name = null;
Type = null;
}
public void setFileType(String n, String t) {
Name = n;
Type = t;
}
public int compareTo(FileType ft) {
String decodedFileName = null;
String decodedInputName = null;
try {
decodedFileName = URLDecoder.decode(this.Name, "UTF-8");
decodedInputName = URLDecoder.decode(ft.Name, "UTF-8");
}
catch(UnsupportedEncodingException e) {
}
return decodedFileName.compareToIgnoreCase(decodedInputName);
}
}
Above code is my define class for file list.
I had implement compare file name.
The type may Folder or File.
But I want to sort file first priority is Type, and second priority is Name.
How can arrive it?
extends Objectis redundant and prevents legitimate inheritence.compareToimplementation uses neither name nor type. I'm confused when I read your code. And you don't follow the Sun coding standards, which is a bad sign to me.