Now, I know that no anonymous class is created becaus there is no longer the Foo$999.class file to be seen. But does such code not create a Runnable object behind the scenes?Cay Horstmann wrote:. . . That's a lot better than making a Runnable.
Isn't that “when many more programmers use[d] it”?As for streams, I would agree that it's a bit more advanced. In Core Java, it's in Volume II. That might change if the stream library became a bit more user-friendly, or if many more programmers used it.
Cheers,
Cay
Campbell Ritchie wrote:Which of these two are you going to prefer?
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Rob Spoor wrote:If it weren't for the necessary <String> (because the call to reversed() makes type inference a bit wonky):
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Campbell Ritchie wrote:But the idea was to show a λ in use.
I think this thread might well be duplicated in the Java8 forum.
What, so it can't be anything else?Ken Duncan wrote:However, my essential point initially was that Java is supposed to be object-oriented.
No, but they are based on a class. And moreover, you can write one yourself.As far as I can see, lambda expressions don't belong to any class.
No they're not. C has no execution-time binding.They are indeed more like a C function embedded in Java code.
I agree.I think the object-oriented paradigm is a good one.
No; but does that necessarily make them bad?Lambdas are not OO.
Only because you haven't written one. They ARE a class - or at least, a lambda expression is based on a class that implements a functional interface (although I believe the compiler is quite clever about stuff like that, so it doesn't actually have to be annotated with @FunctionalInterface) - so you could make one a member of any class you write.They are not a member of a clss I defined. They are not methods of a class I defined.
They may do. It depends what the method they're based on does.Do lambda expressions cause an object to be instantiated?
No, but any stack trace you get will be thrown by a real Java class, which will be a functional interface. In many cases you may not have written it, but this is no different to getting a stack trace from a method in ArrayList or HashMap.My objection is primarily, though not exclusively, conceptual, not syntactical. I will be interested to see what this looks like in a stack trace because it does not belong to anything I instantiate, if I understand lambdas correctly.
I am clearly not as comfortable with Java 8 features as many.
Surely you are telling the compiler to create an object to encapsulate that function.Stephan van Hulst wrote:. . . treating a function as if it's an object . . .
Stephan van Hulst wrote:One could write such a language that compiles to Java byte code.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Straws are for suckers. Now suck on this tiny ad!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
|