primary key für java klasse?


Erfahrenes Mitglied
Sowas wie ne id bekommst wie folgt:

public class Main {

   public static void main(String[] args) {
     IDObject io = new IDObject();
     IDObject io2 = new IDObject();

class IDObject {
   private String blub;
   private String blob;
   public String getBlub() {
     return blub;
   public void setBlub(String blub) {
     this.blub = blub;
   public String getBlob() {
     return blob;
   public void setBlob(String blob) {
     this.blob = blob;


Und was google noch dazu sagt:
Uniqueness isn't necessarily guaranteed, note. The Sun JVM implementation will give you a value which is related to the original memory address for this object, but that's an implementation detail and you shouldn't rely on it.

Viele Grüße