Last active
January 5, 2019 15:30
-
-
Save RashidJorvee/5f4910326243ec2ea32d274803a83c92 to your computer and use it in GitHub Desktop.
Return list of objects from a method in 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
package rashid.jorvee; | |
import java.util.Arrays; | |
import java.util.List; | |
public class ReturnMultipleValueFromMethod { | |
public static void main(String[] args) { | |
List<Object> list=getQuestionAndViewType("M", "Survey"); | |
System.out.println(list); | |
/* if you want to fetch a single value from list then use get() method with index number.*/ | |
System.out.println(list.get(0)); | |
} | |
public static List<Object> getQuestionAndViewType(String questionTypeEpsilon, String format){ | |
String questionType=""; | |
String viewType=""; | |
if(format.equals("Survey") && questionTypeEpsilon.equals("M")) { | |
questionType = "multipleChoiceQuestion"; | |
viewType = "question-answer-short-text"; | |
} | |
else if(format.equals("Survey") && questionTypeEpsilon.equals("S")) { | |
questionType = "singleChoiceQuestion"; | |
viewType = "question-answer-long-text"; | |
} | |
else if(format.equals("Quiz") && questionTypeEpsilon.equals("S")) { | |
questionType = "singleChoiceQuestionInteractive"; | |
viewType = "question-answer-long-text"; | |
} | |
else if(format.equals("Quiz") && questionTypeEpsilon.equals("M")) { | |
questionType = "multipleChoiceQuestionInteractive"; | |
viewType = "question-answer-short-text"; | |
} | |
return Arrays.asList(questionType,viewType); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output: