4

I am learning Scala and it introduced variance. Since Scala runs on JVM, I tried to understand variance in terms of Java, but it lead me to confusion. I need a clear understanding of the following:

  1. What is call-site variance and declaration site variance ?

  2. Which one is supported in Java ?

  3. How are these types different from bounded wildcard or bounded parameter?

  4. How do they differ in Scala and Java?

Matt
  • 12,848
  • 2
  • 31
  • 53
optional
  • 3,260
  • 5
  • 26
  • 47
  • 1
    You might find this answer useful: http://stackoverflow.com/questions/4231305/how-does-javas-use-site-variance-compare-to-cs-declaration-site-variance These are well known questions IMHO. Just use google. – Sohaib Mar 22 '16 at 06:26
  • 1
    @Sohaib : I have gone through all of possible answers available, but found no one complete because i want a comparison of them in terms of scala and Java – optional Mar 22 '16 at 06:33
  • There is a comparison between java and scala in the above mentioned link. Don't go by the title :) – Sohaib Mar 22 '16 at 06:38
  • That only shows syntactical difference with definition for call-site variance(as I think so) What i want all the point mentioned and their equivalent in java/scala with their difference – optional Mar 22 '16 at 06:41
  • „*…What i want all the point mentioned and their equivalent in java/scala with their difference…*“ – optional — Hi. Given that it's been 4.5 years since you asked this question, I presume that, by now, you will have learned everything that you would need know to be able to list those point-by-point differences yourself. I'm sure I wouldn't be the only one grateful to you if you found the time to answer your own question and list all those differences. You would probably also find, that just writing stuff down to share with others is a great memory aid to make stuff stick in memory better. TIA. – deduper Sep 21 '20 at 19:56

0 Answers0