Skip to content
Advertisement

Tag: interface

How can I create a stream of objects?

Let’s say I have: and Then in a service, I have: It is not allowed to do the following: But ultimately, I have other classes that would share this interface and would want to do: Is there a way around this? Like using flatMap? (I noticed that if I have a wrapper class on a List of SomeClass objects, I

access interface out of the class java

I have a class A, another is B, there is one interface Ai with one method ok() only. Class A implements Ai, inside the ok I’m printing just a line. Class B has an instance of A, I want to access A’s interface Ai inside B. Can it be done ? If so how ? Answer All I needed is

Is it better practice to use static factory methods over an interface implemented by many different objects? [closed]

Closed. This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 3 years ago. Improve this question It seems as though you could either use static factory methods or you can use an interface that many objects implement

Android MVP – Calls the server

I started to learn MVP but I have a few questions related the communication between the Model and the Presenter, for example a login feature Activity will get all the fields, send to the presenter, the presenter will validate and if it’s everything as expected the presenter will call the model to send to the server, but this call could

Java strange class cast exception

Could anyone help me understand why in 1 situation I do not have ClassCastException? At least String::trim is not a MagicFunction. Answer So, method references (like String::trim) are a bit weird; unlike most expressions in Java, they don’t really have a type of their own. Something like this: won’t even compile, because it doesn’t give the compiler enough information about

Advertisement