Last active
September 11, 2019 01:48
-
-
Save HoweChen/399a7954745f4dcf48ca12f857fe5ddd to your computer and use it in GitHub Desktop.
[Java 当中返回多个返回值]#Java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class App | |
{ | |
public static void main( String[] args ) | |
{ | |
TestService testService = new TestServiceImpl(); | |
String name = "testName"; | |
EnumMap<TestService.UserInfoProperty,Object> userInfo = testService.getUserInfoByName(name); | |
userInfo.entrySet().iterator(); | |
System.out.println(userInfo.get(TestService.UserInfoProperty.Name)); | |
System.out.println(userInfo.get(TestService.UserInfoProperty.ROOM)); | |
System.out.println(userInfo.get(TestService.UserInfoProperty.CELLPHONE)); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.EnumMap; | |
public interface TestService { | |
enum UserInfoProperty { | |
ROOM,CELLPHONE,Name | |
} | |
public EnumMap<UserInfoProperty,Object> getUserInfoByName(String name); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TestServiceImpl implements TestService { | |
@Override | |
public EnumMap<UserInfoProperty, Object> getUserInfoByName(String name) { | |
EnumMap<UserInfoProperty,Object> retMap = new EnumMap<UserInfoProperty, Object>(UserInfoProperty.class); | |
retMap.put(UserInfoProperty.ROOM,"0003"); | |
retMap.put(UserInfoProperty.CELLPHONE,"00004"); | |
retMap.put(UserInfoProperty.Name,name); | |
return retMap; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment