标签云

微信群

扫码加入我们

WeChat QR Code


... that would break everything.

2018年09月26日37分52秒

This actually won't compile, as ints are not subclasses of Object

2018年09月27日37分52秒

usually, what is meant by dynamic is that one could then call methods on the var and they would work if the runtime type had the method. So in your case, calling temp.length() would not work without a cast. Dynamic implies runtime type checking, not compile-time

2018年09月26日37分52秒

I added a better example that hopefully better shows the benefit.

2018年09月26日37分52秒

Sorry about my bad example -- I added a better example.

2018年09月27日37分52秒

#2: Just because it was designed one way doesn't mean that it would not be beneficial another way. That logical would have prevented many recent changes -- generics, for each, enum, etc. #3: Sorry I wasn't clear -- meant a language that supports both.

2018年09月26日37分52秒

That logic could be used to say that everything dangerous should be hard to avoid abuse. for loops, threads, etc can be abused so do you think they should be hard also?

2018年09月27日37分52秒

It might be -- it might be possible to implement it without reflection -- the point is that some languages (LISP, python, Ruby) are built entirely on this, and their users find it useful -- I think that would be true in Java too (for some applications)

2018年09月26日37分52秒

One of features of Java is lack of features. Java makes it harder to shoot yourself in foot. And, well,bad programmers happen... and working with bad code happens. With dynamic types Java would reach new levels of bad code.

2018年09月26日37分52秒