Java.lang.Void and Void

Source: Internet
Author: User

java.lang.Voidis analogous to java.lang.Integer . is Integer A-a-boxing values of the primitive type. is int A-a-on-the- Void boxing values of the Primitive type void .

"But wait, void doesn ' t has any possible values!"

right! That's what makes java.lang.Void "uninstantiable".:)

It's a nice feature of the Java type system, every primitive type has a boxed equivalent. int Integer has, long have Long , has ... and byte Byte void Void has. It would be weird and asymmetrical if Void didn ' t exist.

"So what's the difference between and java.lang.Void void ?"

Easy. is void a primitive type. Void is a reference type that inherits from Object . They ' re similar in that neither of them have any possible values; But nevertheless they is the very different types, from the type system's point of view.

"But I don ' t has any with for in Void my programs."

and I don ' t has any with the in GarbageCollectorMXBean mine. Some features don ' t have non-obscure uses. That ' s okay.

The only point Void Void.TYPE was to hold and which is the sort of void.class . If you had a reflective reference to a method, then returns void , and you get the its return type, it ' ll return Void.TYPE .

Java.lang.Void and Void

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.