We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Java
- Advanced
- Java Factory Pattern
- Discussions
Java Factory Pattern
Java Factory Pattern
Sort by
recency
|
151 Discussions
|
Please Login in order to post a comment
my Code :
import java.io.; import java.util.;
interface Food {
}
class Cake implements Food{ public String getType(){
}
class Pizza implements Food{ public String getType(){
}
public class Solution {
}
return order.equals("cake") ? new Cake() : new Pizza();
Why on earth teach such bad habits on such a basic question. Where is the use of constants or enum?
If you're new and not seeing any of the prepopulated code, be sure to switch your language to an older version. Some new versions like Java 15 do not have the initial code. This is because Hackerrank is terrible.
Only one line of code