Compiler Error J0037

A method cannot be 'transient' or ‘volatile’

The compiler detected one of the modifiers shown above used in the declaration of a method. The modifiers transient and volatile can only be applied to field declarations.

The following example illustrates this error:

public class Simple{
   
   transient void Method1(){};
   volatile void Method2(){};
   //error: the methods above have invalid modifiers
   
}