-3
import acm.graphics.*;
import acm.program.*;
import java.awt.*;

      public class MyRobot extends GraphicsProgram {
        }
 }

That is the code I wrote and whenever I put extends GraphicsProgram or ConsoleProgram, it tells me

The serializable class MyRobot does not declare a static final serialVersionUID field of type long.   

Also, when I try to run a program with this warning, it just shows a blank program.

Anyone can help me with these problems?

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433

3 Answers3

3

It's because your class is Serializable.

Serializability of a class is enabled by the class implementing the java.io.Serializable interface. Classes that do not implement this interface will not have any of their state serialized or deserialized. All subtypes of a serializable class are themselves serializable. The serialization interface has no methods or fields and serves only to identify the semantics of being serializable.

TomJ
  • 5,389
  • 4
  • 26
  • 31
1

The program likely displays nothing because no components have been added and nothing has been drawn in it. But then, unless you are using one of those tricky IDEs that creates an invisible main() or there is another class besides MyRobot, I fail to see how this code could run.


BTW - forgot to mention the 'quick-fix' to this in Eclipse is:

  1. Double click the warning in the Problems tab, to focus the problem class.

  2. Type Ctrl 1 for 'Quick Fix'

  3. Select the first or second options that appear below.

Eclipse SerrialVersionUID Quick Fix

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
  • sorry but i didnt add the code inside cuz i dinndnt thing i was necassary. – user1290535 Mar 24 '12 at 22:00
  • 3
    How do you know what is relevant/necessary until the problem is solved? Please don't use made up words like 'cuz'. That word is 'because'. It helps people to be able to help *you.* – Andrew Thompson Mar 24 '12 at 22:03
1

Be kind to java. You use classes that have Serializable interface. They need you to declare a static final serialVersionUID field of type long. They ask you to do it. Be so kind, declare a static final serialVersionUID field of type long. :-). And +1 for it is not a bad question for a newbie.

Gangnus
  • 24,044
  • 16
  • 90
  • 149