What is the difference between java.lang.Void and void?

前端 未结 6 550
心在旅途
心在旅途 2020-11-29 03:27

In API

\"The Void class is an uninstantiable placeholder class to hold a reference to the Class object representing the Java keyword void.\"

6条回答
  •  一生所求
    2020-11-29 03:53

    Void is a AutoBoxing feature (since JDK 1.5) of void.

    well its self explanatory that Void is reference whereas void is a primitive type.

    So, where the requirement comes to have to use Void ???

    One common usage with Generic types where we can't use primitive.

    Say, in case of Android AsyncTaks what if I don't want to get Progress update. I can't use void (primitive type) here we require java.lang.Void

提交回复
热议问题