Perhaps you mean sth like this:
Object o = new Object(){ int count = 5; String message = "A string."; };
@Commenters : this, of course, is a theoretical, very inconvenient example.
Probably the OP can use Map :
Map<String,Object> a = new HashMap<String,Object>(); a.put("Count", 5); a.put("Message", "A string."); int count = (Integer)a.get("Count");
zacheusz
source share