Friday, April 24, 2015

Fields in an Interface

All fields in an Interface are automatically set to be 'public static final', means they are constants by default.


==============================================
===== FunBoy.java===================
public interface FunBoy {
int NUM = 3;
}
--------------------------------------------


=========================================
=======FunBoy.class=========

public interface FunBoy
  SourceFile: "FunBoy.java"
  minor version: 0
  major version: 50
  flags: ACC_PUBLIC, ACC_INTERFACE, ACC_ABSTRACT
Constant pool:
   #1 = Class              #2             //  FunBoy
   #2 = Utf8               FunBoy
   #3 = Class              #4             //  java/lang/Object
   #4 = Utf8               java/lang/Object
   #5 = Utf8               NUM
   #6 = Utf8               I
   #7 = Utf8               ConstantValue
   #8 = Integer            3
   #9 = Utf8               SourceFile
  #10 = Utf8               FunBoy.java
{
  public static final int NUM = 3;
    Signature: I
    flags: ACC_PUBLIC, ACC_STATIC, ACC_FINAL
    ConstantValue: int 3


}

No comments:

Post a Comment