Why do we need a magic number in the beginning of the .class file?

前端 未结 4 1078
陌清茗
陌清茗 2021-01-01 23:58

I read a few posts here about the magic number 0xCAFEBABE in the beginning of each java .class file and wanted to know why it

4条回答
  •  佛祖请我去吃肉
    2021-01-02 00:55

    The magic number is basically an identifier for a file format. A JPEG for example always starts with FFD8. It is not necessary for Java itself, it simply helps to identify the file-type. You can read more about magic numbers here.

提交回复
热议问题