Skip to content
Advertisement

Tag: abstract-class

Abstract Classes & Methods In Java

I am working on a Java exercise where a parent class is abstract, and the subclasses override the isSimilar method. This method should take a device parameter. In the Server subclass, this method should compare the Brand, Operating System, and Available Services. In the NetworkDevice subclass, this method should compare the Brand, Number of Ports, and Power Over Ethernet. The

Java: Abstract class with builder pattern

I hope this isn’t a duplicate; I know there are some similarly named questions but none of them seemed to solve my problem. I have multiple classes that are exactly the same – apart from one specific method. So I decided to create one abstract parent class, let’s call it A. A runs all the code and has one method

How to properly unwrap an optional in Java?

I am learning the basics of Java and I am exploring Optionals and abstract classes so I came across the following issue, I have this code I was expecting to see the prints on the console “It is a Dog” followed by 2 “It is not a Dog” Since I’m using the method .isPresent() on optionals, But I got 1

Abstract class with Gson serialization/deserialization

I am expecting to get from a json a LinkedList<Request>. The pojos look like this: The serialization works fine, it generates the json, but it crashes at deserialization (maybe it’s the abstract class or/and that I am expecting a LinkedList and/or the lombok annotations)? I tryed writting a gson deserializer (quite a standard one found googling), but it doesn’t do

Advertisement