Java is a beautiful little place than. Net

Source: Internet
Author: User

After four years of. NET, this year's turn to Java, the heart has been spit slot Java cumbersome, today found a Java worthy of my praise for the place

Java enumeration Incredibly can play like this, not much nonsense, on the demo

 PackageCom.sunline.sms.common; Public enumErrorCode {e0000 {@Override PublicString GetCode () {return"0000"; } @Override PublicString GetDesc () {return"Trading Success"; }}, e0001 {@Override PublicString GetCode () {return"0001"; } @Override PublicString GetDesc () {return"Parameter is empty"; }}, e0002 {@Override PublicString GetCode () {return"0002"; } @Override PublicString GetDesc () {return"Please get the text again"; }}, e0003 {@Override PublicString GetCode () {return"0003"; } @Override PublicString GetDesc () {return"SMS has Expired"; }}, e0004 {@Override PublicString GetCode () {return"0004"; } @Override PublicString GetDesc () {return"The verification code exceeds the number of errors, please re-get"; }}, e0005 {@Override PublicString GetCode () {return"0005"; } @Override PublicString GetDesc () {return"Verification code error, please reenter"; }}, e9000 {@Override PublicString GetCode () {return"9000"; } @Override PublicString GetDesc () {return"Get Verification Code failed";    }    }    ;  Public AbstractString GetDesc ();  Public AbstractString GetCode ();}

Use as follows:

Throw New ProcessException (ErrorCode.e0001.getCode (), ErrorCode.e0001.getDesc ());

Java is a beautiful little place than. Net

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.