• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JLS 4.3.4, When Reference Types Are the Same

 
Rupak Khurana
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could someone pls explain the JLS 4.3.4 with an example?
That would be very kind of you...
 
Devender Thareja
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As far as I understand the specs, following are the examples you are looking for.

ArraList<String> a, b;
StringBuffer c,d;
Comparable g, h;
MyClass e, f;

Here a and b are same compile time type. And so are 3 other pairs:
c and d
g and h
e and f.

For same run-time type, I am not 100% confident, but it seems that these variables if point to same objectType then they would be called same run-time type.
For example if MySubclass extends MyClass, then:
e = new Mysubclass(); f=new Mysubclass(); // same runtime-type
e = new MyClass(); f=new MyClass(); // same runtime-type
e = new MyClass(); f=new Mysubclass(); // Different runtime-type
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic