In Java everything, except for primitive types are references. String
is not considered a primitive type, but char
is. So, AFAIK 'a' in your example is not a reference.
However, Java supports autoboxing, so if you try to use 'a' as an object it will probably work just fine, as if it were a reference.
Update: some examples may help here:
char a = 'a';
char b = 'a';
System.out.println(a == b); // true
String c = "a";
String d = "a";
System.out.println(c == d); // Dunno; may be true if the compiler created a single object for c and d, otherwise it's false
String e = new String("a");
String f = new String("a");
System.out.println(e == f); // false