I was wondering if there exists a similar functionality in Java similar to C#\'s anonymous types:
var a = new {Count = 5, Message = \"A string.\"};
No. There is no equivalent. There is no typeless variable declaration (var) in Java that the Java compiler could fill in with the auto-generated type name to allow a.Count and a.Message to be accessed.
var
a.Count
a.Message