Is it possible in java not to give the function name and still call it?
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
Is it possible in java not to give the function name and still call it?
vanshika..
Can you give an example of a java method that you are asking about.
If you don't understand my answer, don't ignore it, ask a question.
this is a question asked in an interview..Now i got the answer.
Here it is:We have the concept of "Anonymous Class" in java i.e a class without a name or we can declare and instantiate a class at the same time.They are like local classes except that they do not have name.
Now, Anonymous function is a function which is declared and called but without a name. In most of the programming languages,anonymous function have been used with the keyword lambda and that is why they are also known as lambda functions.
Programming languages that support anonymous functions are: LISP,JavaScript,Ruby,etc.
Java does not contain this feature.However,Java8 is planning to contain this feature.
And we can call the anonymous function by passing it into a variable and call it.
vanshika..