Please Help


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Please Help

  1. #1
    Join Date
    Dec 2002
    Posts
    3

    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;


    }


    }

  2. #2
    Join Date
    Nov 2002
    Posts
    138
    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.

  3. #3
    Join Date
    Nov 2002
    Posts
    138
    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
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center