I have a public method (called getMusic) in a class called Favorites. getMusic has set. There are 3 sets and in each set has five words, Set getMusic(). In another class ...
I have to create a course with some undergraduate and postgraduate students, then extract from the course all postgraduate students with “Ismael Bento” as their supervisor using the method getPostgraduates() and ...
public interface Segment<T> extends Period { ... };
public class SegmentImpl_v1<T> implements Segment<T> { ... };
public interface TimeLine<T, S extends Segment<T>> { ... };
public class TimeLineImpl<T, ...
Your declaration is for a variable "s", while the error message is about code related to a variable called "set". Apparently both of these are Sets, and you seem to think that they have something to do with each other. But I suspect that the compiler considers "s" and "set" to be two different things. Perhaps you could show us the ...
thanks static was the reason why states were called the same. It adds fine now thanks :) However... ive added them to a LinkedHashSet so that the order in which they are inserted are preserved. How would I retrieve say state 4 as an object of type State from the LinkedHashSet and apply a certain method to it from the State ...
Ok, I am using bluej and I am having trouble using a loop to add to a HashSet, as it just returns the size as null, saying there is nothing in it and I don't understand why. public Pack() { HashSet
From the plethora of information I'll say that you are not holding your tongue correctly. What does "all the others are rejected" mean? Is there some sort of error appearing? Is your application crashing? Does nothing crash/no errors and afterwards your set only contain one value? How did you determine that there is only one value in your set? The more ...
Error: java.lang.ClassCastException: com.WeatherReport at java.util.TreeMap.compare(TreeMap.java:1093) It appears that com.WeatherReport objects are not comparable, and result in this ClassCastException when the 2nd object added to the TreeMap is compared to the 1st object, so that they can be ordered. Do you need to implement a comparator/comparable condition? My Java version appears to be different from yours, as line number 1093 is meaningless ...
You'd have to ask the original author of the class why he chose to do that. Maybe he wanted to decouple that value from the specific backing Map implementation. Currently the backing Map is HashMap, which allows null values, but some Maps don't. If they decide to change the backing map to one that doesn't allow null, they don't have to ...
First cross check the code written in addPosition method. Second the constructor of Portfolio class: Portfolio portfolio = new Portfolio(null); when you do this, it sets the null to reference variable of position class i.e _position = null, and in addPosition method you are adding this variable to Hashset. After correcting the above points if it still won't work, then i'll ...