java,jdk1.7 The following switch how to use string types

Source: Internet
Author: User

use an enumeration to go to a string /**
* Enumeration
*/
Private enum supegroup{
J1,J2,J3,J4,J5,J6,J7,J8,JZ

}
/**
* String Goto enumeration
* @param str
* @return
*/
Public supegroup Tosupegroup (String str) {
return supegroup.valueof (str);
}
switch (Tosupegroup (supegroupcode)) {
Case J1:
str= "supervising a group";
Break ;
Case J2:
str= "supervising two groups";
Break ;
Case J3:
str= "supervising three groups";
Break ;
Case J4:
str= "supervising four groups";
Break ;
Case J5:
str= "supervising five groups";
Break ;
Case J6:
str= "supervising six groups";
Break ;
Case J7:
str= "Supervision of seven groups";
Break ;
Case J8:
str= "Supervision of eight groups";
Break ;
Case JZ:
str= "Technical quality Group";
Break ;
}

java,jdk1.7 The following switch how to use string types

Related Article

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.