Would it be useful to change java to support both static and dynamic types?
Posted
by
James A. N. Stauffer
on Stack Overflow
See other posts from Stack Overflow
or by James A. N. Stauffer
Published on 2008-09-19T03:32:45Z
Indexed on
2011/02/20
15:25 UTC
Read the original article
Hit count: 194
java
|language-design
What if a Java allow both static and dynamic types. That might allow the best of both worlds. i.e.:
String str = "Hello";
var temp = str;
temp = 10;
temp = temp * 5;
- Would that be possible?
- Would that be beneficial?
- Do any languages currently support both and how well does it work out?
Here is a better example (generics can't be used but the program does know the type):
var username = HttpServletRequest.getSession().getAttribute("username");//Returns a String
if(username.length() == 0) {
//Error
}
© Stack Overflow or respective owner