Table 2–11 shows the methods available in the MapMessage interface for adding content to the body of a map message. Each of these methods takes two arguments, a name string and a primitive or string value of the appropriate type, and adds the corresponding name-value pair to the message body: for example,
StreamMessage  outMsg = mySession.createMapMessage();
outMsg.setInt("The Meaning of Life", 42);
Table 2–11  Map Message Composition
Methods| Name | Description | 
|---|---|
| Store integer in message map by name | |
| Store byte value in message map by name | |
| Store byte array in message map by name | |
| Store short integer in message map by name | |
| Store long integer in message map by name | |
| Store floating-point value in message map by name | |
| Store double-precision value in message map by name | |
| Store boolean value in message map by name | |
| Store character in message map by name | |
| Store string in message map by name | |
| Store object in message map by name | 
Like stream messages, map messages provide a convenience method (setObject) for dealing with values whose type is determined dynamically at execution time: for example, the statements
Integer  meaningOfLife = new Integer(42);
outMsg.setObject("The Meaning of Life", meaningOfLife);
are equivalent to
outMsg.setInt("The Meaning of Life", 42);
The object supplied must be either a string object (class String) or an objectified primitive value of class Integer, Byte , Short, Long, Float, Double, Boolean, or Character; otherwise an exception (MessageFormatException) will be thrown.