Is there a similar way to declare a c-expression in Java (as in Javascript) or are there structural reasons why this is not possible?
For example, this Javascript:
with(obj) { getHomeworkAverage(); getTestAverage(); getAttendance(); }
... nice and easy. However, it would seem that method calls should be bound to their object (s) every time in Java, without such graceful shortcuts available:
obj.getHomeworkAverage(); obj.getTestAverage(); obj.getAttendance();
This is very redundant and especially annoying when there are many ways to call.
- So, is there a similar way to declare a statement operator in Java?
- And if it is possible not , what are the reasons why it is possible in Javascript compared to the impossible in Java?
source share