Java pair selection.
Not what you're looking for?
I need to write a generic class Pair which has two type parameters F and S (first and second) each representing the first and second elements of the pair. Add get and set elements so that the values of the pair can be changed.
This is an example of the code of the test class that calls for the pair class.
public class PairTest
{
public static void main( String args[] )
{
// create pair of integer and string
Pair< Integer, String > numberPair =
new Pair< Integer, String >( 1, "one" );
// display original numberPair
System.out.printf( "Original pair: < %d, %s >n",
numberPair.getFirst(), numberPair.getSecond() );
// modify pair
numberPair.setFirst( 2 );
numberPair.setSecond( "Second" );
// display modified numberPair
System.out.printf( "Modified pair: < %d, %s >n",
numberPair.getFirst(), numberPair.getSecond() );
} // end method main
} // end class PairTest
Purchase this Solution
Solution Summary
The expert examines a Java pair selection for two type parameters.
Purchase this Solution
Free BrainMass Quizzes
Basic Computer Terms
We use many basic terms like bit, pixel in our usual conversations about computers. Are we aware of what these mean? This little quiz is an attempt towards discovering that.
Inserting and deleting in a linked list
This quiz tests your understanding of how to insert and delete elements in a linked list. Understanding of the use of linked lists, and the related performance aspects, is an important fundamental skill of computer science data structures.
Excel Introductory Quiz
This quiz tests your knowledge of basics of MS-Excel.
Basic UNIX commands
Use this quiz to check your knowledge of a few common UNIX commands. The quiz covers some of the most essential UNIX commands and their basic usage. If you can pass this quiz then you are clearly on your way to becoming an effective UNIX command line user.
Basic Networking Questions
This quiz consists of some basic networking questions.