Java Lambda expressions [closed] - java

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
Lambda expressions are being added in Java 8. I want to understand why this is important. What does it mean to a Java programmer who is yet to be exposed to functional programming idioms? Does it mean I can write code that performs better or scales massively or does it only make the code less verbose. Or all of it.

Oracle already has tutorial up on the topic. It lists several great uses cases.
Before I found the link, I was going to say that lambda expressions let you pass "functions" to code. So you can write code more easily that we used to need a whole mess of interfaces/abstract classes for. For example, suppose you have code that has some complex loop/conditional logic or workflow. At one step you want to do something different. With lambda expressions, you can just pass in that "something different." Read the tutorial though. It's very clear.

Related

Why does Java Stack have a search method? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
From what I know about stacks, it seems like this method goes against the whole point of a stack- if you need to know where in your stack a specific element is then why are you using a stack at all?
Edit: I'm not trying to waste anyone's time or ask dumb questions, I'm a student who's honestly just trying to figure out the rationale behind this function so that I can become a better programmer
I would put it like that:
Java has its inconsistencies and this is one of them.
If you take a deeper look you will find that Stack is a subclass of Vector and inherits its mehtods which also seem to make not that much of a sense.
Programming languages are living and growing things made by people and I think you can always find things that don't make sense or things that you wish would have been made in a better way (whatever 'better' means).
In some you will find more in some you will find less flaws.

Run a math expression from string in java [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I want to know if there is any efficient method to Run a math expression from string in java , Having some example input and results of that function.
Starting from simple linear functions : a*x+b .To more complex ones
Or is there any good source i can start reading.
I take your task as: take observed input-output and learn some representation which is able to do that transformation with new inputs.
(Some) Neural Networks can learn an approximation-function (Universal approximation theorem
) (and probably other approaches), but there is something important to remark:
Without assumptions about your function (e.g. smoothness), there can't be an algorithm achieving what you want to do! Without assumptions there are infinite many approximation-functions, which are all equally good on your examples, but behave arbitrarily different on new data!
(I'm also ignoring special-cases as: random-data or cryptographic random-generators where this mapping also can't be learned (the former in theory; the latter at least in practice)

user defined functions vs built in function in java five relevant differences over time and space complexities [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Please explain me the differences over time and space complexities in java for user defined and predefined functions in java. examples like, linked list, list, stack class. please explain this with valid example.
thank you.
There is nothing special in predefined function over user defined. The only thing is predefined has been written by somebody else for you. It depends on algorithm.
Crap code/implementation runs in a crap way. Doesn't matter if its user created or system/API provided. example at a high level is EJBs vs Spring.
Good written code runs pretty and sleek. Again doesn't matter who the hell wrote it.

What would be your interpertation of this requested queue implementation? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I had been reading two books on JAVA and while covering data structures, I started to do some online research with regards to "QUEUE" implementation. I have an extensive background in FLEX, however ACTIONSCRIPT isn't comparable to advance languages.
Lets say if I was on a job interview and asked to implement a Queue of Object, how should I pursue it as? I am not looking for code help here, I would like to what would you quick answer be? I have been to Java online docs and do understand there are 13 known implementing classes, and "LinkedList" is one of them.
Google search has return more results with "LinkedList" implementation code than any other.
My apologies if you find this question to be rubbish or pointless in anyway.
Oracle's Java online doc ref:
Do you know what the concept of a queue is and how it differs from a stack (closely related data structure)? If so, you should be able to think of multiple ways to implement it.
Which is best depends on the exact requirements of the task it's being used to address.
So the right response to that interview question is not to start coding but to ask them for more information about the requirements your implementation has to address. Performance? Memory size? Multitasking? Any limits on maximum queue depth, eg to guard against things like a DOS attack? What's being enqueued -- objects, primitives, other? Specific kinds thereof? Parameterized type? Are there any values which should be discarded (maybe null shouldn't be enqueued)?
Knowing the requirements, you should be able to judge which answer is appropriate. Starting coding without asking the requirements is immediately going to earn you a demerit.

Java Questions [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I'm TAing for an introductory course in Java for freshmen. So, far we've learnt most of Java except the OOPS part. Like we can do methods, loops, control stuctures, arrays, strings, recursion etc..
Since this is their first programming course, they are not aware of fancy datastructures yet.
I have dont most of the regular programs like factorial, fibonacci, primes etc..
I'm looking for some interesting problems in the space without using complex datastructures. Any ideas would be super helpful.
thanks, Vinbot
Project Euler has some problems that you can solve without additional data structures, and all the problems have the nice property of being mathematically interesting. Not all the problems will work for your course, but I bet you can find enough that do, especially among the first few.

Categories