Vasil Valchev
Vasil Valchev

Reputation: 5819

Java OOP case for object type answer

I have this simple oop case and wondering what is the best practise to implement / design my classes:

public class AnswerString {
   String answer;
}

public class AnswerInteger {
   int answer;
}

public class AnswerBoolean {
   boolean answer;
}

I need to combinate this class in single one and use it in array adapter, array list, sqlite db etc...

public interface / abstract class Answer {
   ???
   getAnswer()
}

Upvotes: 1

Views: 49

Answers (1)

Alex Shutov
Alex Shutov

Reputation: 3282

try to create Answer class and store your value as Object along with class type (String, Integer, Boolean), or use generics

Upvotes: 1

Related Questions