in my app in swift I have this code:
struct Question
{
var QuestionLbl : String!
var Answers : [String]!
var Answer : Int!
}
After that I use this struct like this
var Questions = [Question]()
Questions =
[Question(QuestionLbl: "Whats my name?", Answers: ["John","Josh","Adam","Leo"], Answer: 0),
Question(QuestionLbl: "Whats my moms name?", Answers: ["Jessica","Crystal","Samanta","Kate"], Answer: 3),
Question(QuestionLbl: "Whats my fathers name?", Answers: ["Ed","Blake","Jeff","Jonhson"], Answer: 2)]
Now, I'm trying to make the same app for Android.. So I created a class and tried to do the same thing like that.. This is the class file:
public class Question {
String questionLabel;
String[] answersOptions;
Integer correctAnswer;
public Question(String questionLabel, String[] answersOptions, Integer correctAnswer) {
this.questionLabel = questionLabel;
this.answersOptions = answersOptions;
this.correctAnswer = correctAnswer;
}
public String getquestionLabel() {
return questionLabel;
}
public String[] getanswersOptions() {
return answersOptions;
}
public Integer getcorrectAnswer() {
return correctAnswer;
}
}
and this is how I try to do in main activity:
Question[] questions;
questions = {
Question("Whats my name?",{"John","Josh","Adam","Leo"}, 1),
Question("Whats my mom's name?",{"Jessica","Crystal","Samanta","Kate"}, 1)
};
But it didn't work. Whats is the problem?