Is there a NameIdPair-Class ?

syska

Grünschnabel
Hi,

i try to find a java system class, which is able to store 2 or even better 3 values. Something like:
Code:
public class NameIdPair
{
      private int id;
      private String name;

      public void setId( int id );
      public int getId();
      public void setName( String name );
      public String getName();
}

The problem is, that i can´t use my own class, so it must be a system class. Does anyone know a likewise class ?
Thanks in advance

Chris
 
Hello,

you could use the java.util.Map.Entry Interface as a base for a "custom/anonymous" Implementation...

Another way is to put the tools.jar in the classpath and use the Pair Class of the Java Compiler

import com.sun.tools.javac.util.Pair;
Pair<Integer, String> pair = new Pair<Integer, String>(1,"ABC");
System.out.println(pair.fst);
System.out.println(pair.snd);

Kind regrads,
Tom
 
Zurück