In java please as soon as possible! gracias! :) should be very simple and quick
ID: 3821212 • Letter: I
Question
In java please as soon as possible! gracias! :) should be very simple and quick :)
Assume that there are two generic classes available
SPair< T > which is a pair of the same type such as two integers or two strings.
DPair < X, Y > which is a pair of different types such as double/boolean or file/string
Both SPair and DPair have constructors which take two arguments to initialize their pair values
1) Declare a variable named strPair which is an SPair of Strings. Initialize it with values "hello" and "goodbye".
2) Declare a variable named ispair which is a DPair of integers and strings. Initialize the pair with the values 56 and "cool".
3) Declare a variable named dbpairs which is an ArrayList of DPairs of doubles and booleans. Initialize the dbpair to be empty
Explanation / Answer
1) SPair<String> strPair = new SPair<String>("hello", goodbye); //Hope that your constructor is implemented this way. Otherwise need more information.
2) DPair<Integer, String> ispair = new DPair<Integer, String>(56, "cool"); //Hope that your constructor is implemented this way. Otherwise need more information.
3) DPair<Double, Boolean>[] dbpairs = new DPair<Double, Boolean>();
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.