Skip to main content
How are we doing? Please help us improve Stack Overflow. Take our short survey

All Questions

4 votes
2 answers
981 views

When is dynamic polymorphism necessary (compared with static polymorphism)?

I come from functional languages (e.g. Haskell) and I enjoy a lot on typeclasses to achieve polymorphism which is also a structural approach to implement ad-hoc overloading. However, recently I'm ...
Ireina's user avatar
  • 386
1 vote
1 answer
10k views

Providing an Empty List to an Optional?

Suppose I have this layout: public void caller(@NonNull List<Integer> param){ // param COULD BE EMPTY, but it CANNOT be NULL, its not nullable if(!param.isEmpty()) function(Optional.of(...
jjot0's user avatar
  • 239
-1 votes
1 answer
237 views

How would I get the minPos without a loop and using only foldLeft?

I am stuck figuring out how I may solve this problem. The goal is to find the position of the minimum value of an Iterable (l) without loops. There is a similar problem here: How would I get the ...
laraveldev17's user avatar
2 votes
1 answer
477 views

How would I get the minVal without a loop and using only foldLeft?

So, I have gotten a bit of an understanding of functional programming but for this I cannot use a loop and instead have to use the foldLeft or foldRight function that I wrote, on order to get the ...
QWERTY's user avatar
  • 25
4 votes
3 answers
4k views

Functional Programming vs OOP [closed]

I just looked up a few examples/definitions of the differences between Functional Programming and OOP. I found one definition that I thought was interesting and I understood the OOP part but needed a ...
sgx's user avatar
  • 1,327
2 votes
3 answers
165 views

Implementing map function

I am creating a 'SpecialList' and am require to implement the map function. The list should be lazy, and will only produce values when evaluated. toString() returns "?" if the value is not yet ...
Iva's user avatar
  • 55
0 votes
1 answer
845 views

Method level Generic Typing for flatMap

I am currently working on a SpecialList implementation of a lazy stream and am required to implement the flatmap feature. public <R> SpecialList<R> flatMap(Function<T, SpecialList<R&...
Iva's user avatar
  • 55
0 votes
3 answers
897 views

Can we apply @FunctionalInterface annotation to abstract classes in Java?

I know it can be applied on interface but as Interfaces with default methods ( Java 8+ Interfaces ) are very close now to abstract classes, Just wondering now can we use @FunctionalInterface with ...
Pramod S. Nikam's user avatar
2 votes
2 answers
90 views

Instantiation of abstract classes [duplicate]

I have been reading this guide on inner classes and came across this interesting example of an anonymous class. So, by default we cannot instantiate an abstract class, e.g. abstract class ...
RnD's user avatar
  • 1,069
-2 votes
2 answers
593 views

Java 8 - What is the real time usecase for return method from another method?

As we know , Java 8 supports functional programming. We can pass method as a parameter and return a method from another method. I know , call back is one of the real time usecase for passing method ...
JavaUser's user avatar
  • 26.4k
2 votes
1 answer
589 views

Analyzing cardinality of types in Java/OOP [closed]

In languages like Haskell, Purescript and Elm it can be powerful to think of types as sets, described here. This tool helps you pick which data structure best fits for your problem. It also allows you ...
Marc's user avatar
  • 744
1 vote
1 answer
300 views

Clojure: is it possible to inherit state of class defined with :gen-class?

I'm trying to study some Java library with Clojure as a working language. The library is (as usual in Java) very object-oriented and needs class hierarchies in client code. I've defined a class ...
Yuriy Al. Shirokov's user avatar
6 votes
4 answers
11k views

Sort a list of lists using comparator

I am looking at sorting out a list of lists (on ArrayLists), using a comparator. Where the order is largest first. All sublists will always be of the same size. For example, a list of [[4,5,6], [7,...
cani's user avatar
  • 210
3 votes
4 answers
261 views

Functional programming in OOP language

immutable objects are OK, but, are OK non-final local references? In other words, next code snippet can be represented as written in functional style? Employee e = new Employee("Lex", 24, 250); e = ...
Lex Ushakov's user avatar
1 vote
1 answer
162 views

Functional programming interfaces in Java

Where can I look for a list of Java standard libraries for functional design patterns? I've heard java.util package contain all of data structures, but I can't find the equivalents of functional ...
MiP's user avatar
  • 483

15 30 50 per page