fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static String enumValue(String type) {
  11. String val = "";
  12. String[] origins = {"VISIT", "RECOMMEND", "LEAFLET", "ACTIVITY", "MEDIA", "MESSAGE", "NET", "PHONESALE", "FRIENDS", "OTHERS"};
  13. String[] educations = {"DOCTOR", "POST_GRADUATE", "COLLEGE", "JUNIOR_COLLEGE", "HIGH_SCHOOL", "MIDDLE_SCHOOL", "SECONDARY_SCHOOL"};
  14. if (type.equalsIgnoreCase("origin")) {
  15. val = origins[(int) (Math.random() * origins.length)];
  16. } else if (type.equalsIgnoreCase("education")) {
  17. val = educations[(int) (Math.random() * educations.length)];
  18.  
  19. }
  20. return val;
  21. }
  22. public static void main(String[] args) {
  23. String sourceId = enumValue("education");
  24.  
  25. System.out.println("名单来源是"+sourceId);
  26. }
  27. }
Success #stdin #stdout 0.09s 27808KB
stdin
Standard input is empty
stdout
名单来源是DOCTOR