-
Please Help
Why i am getting error that my class is not Seriazable?
import java.util.*;
class Comp implements Comparator,Serializable {
private int count = 0;
static public int MAXSETS = 1;
private int a[] = new int[MAXSETS];
private int b[] = new int[MAXSETS];
public int compare(Object a,Object b)
{
Integer a1=(Integer) a;
Integer b1=(Integer) b;
return b1.compareTo(a1);
}
public String toString(){
String str=" ";
for(int i=0;i < count;i++){
str = str+" "+a[i];
// str = str+" "+number[i];
System.out.println("gg"+ str);
}
return str;
}
}
-
i really don't do serializing, but if you posted your code as is, then you should try importing the java.io.Serializable class. java.io classes need explicit importing. or you can use the long version everytime by doing a java.awt.Frame, or java.io.serializable everytime you use a class that is not in java.lang.
-
also NotSerializableException is thrown by a readObject or writeObject method. check your methods which have these since this is most probably what's causing it.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks