Java. Recognize the type of uninitiated reference



  • Explanation of references:

    Wall wall;
    User user;
    

    How do you know the type of reference wall and user? Maybe?

    From what I found:

    https://ru.wikipedia.org/wiki/%D0%94%D0%B8%D0%BD%D0%B0%D0%BC%D0%B8%D1%87%D0%B5%D1%81%D0%BA%D0%B0%D1%8F_%D0%B8%D0%B4%D0%B5%D0%BD%D1%82%D0%B8%D1%84%D0%B8%D0%BA%D0%B0%D1%86%D0%B8%D1%8F_%D1%82%D0%B8%D0%BF%D0%B0_%D0%B4%D0%B0%D0%BD%D0%BD%D1%8B%D1%85#Java ♪ This option is not appropriate because an object is required



  • Unfortunately, no. From the point of view of the virtual machine, there are no variables, there are only values. Because it doesn't matter, you can't check the type. There are also no designs in the language that can do anything during the compilation depending on the type.


Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2