ClassCastException with Set Set Integer

I'm trying to create a set that holds sets of Integers, but I'm running into a weird ClassCastException. The code works fine so long as I'm adding to an empty set; as soon as I try to add a Set<Integer> to the Set<Set<Integer>>, however, the exception is thrown. Isn't this what generics were supposed to prevent? I'm confused. (Sample code is below in case that explanation wasn't clear...)
Any ideas?
Thanks in advance,
Justin
Set<Set<Integer>> masterSet = new TreeSet<Set<Integer>>();
Set<Integer> s1 = new TreeSet<Integer>();
s1.add(1);               
masterSet.add(s1);
Set<Integer> s2 = new TreeSet<Integer>();
s2.add(2);       
masterSet.add(s2); //throws ClassCastException

Well, you know they say, post in haste, repent in leisure.
Your post would have been more helpful if you'd
pointed out that I have to use a HashSet rather than
a TreeSet because neither Set nor SortedSet
implements Comparable (something I hadn't realized).You can use a TreeSet if you really want to, but if you do, you will have to supply a Comparator. Of course, how exactly you would want to compare two sets escapes me.
The Java compiler doesn't give me the errorNo, it cannot, because it doesn't know that the TreeSet was compiled without a comparator.
Perhaps it would have been better to have designed two otherwise equivalent classes, one a TreeSet that could only accept mutually comparable objects, the other that required a comparator at construction-time.
Thanks so much for your help,Welcome, and sorry if I was brusque.
M.

Similar Messages

  • Oracle Application Server 10g R3 with patch set 10.1.3.5.0

    Hi All,
    Can anyone help me on this, When I install Oracle Application Server 10g Release 3 (10.1.3.1.0) and patch set 10.1.3.5.0 on Linux. I am not able to find forms and reports container.
    This version doesn't support forms and reports or I have go OAS 10g R2 (10.1.2.0.2) with patch set 3 (10.1.2.3.0). What is the difference between these two releases.
    Please help me.
    Regards,

    Hi James,
    1)Yes it supports IE 8 .Please review the below link for certification details on browers :-
        http://www.oracle.com/technetwork/middleware/ias/downloads/as-certification-r2-101202-095871.html#BAJGCBEA
         Note: Oracle Application Server supports only those browsers.
    2)Forms only support Windows 7 32 bit only.
        Please refer to the note:1292919.1 "Certification of Oracle Developer Suite 10g (10.1.2) on Windows 7 (32-bit)"
    3)Could you provide more information of JVM because when you install 10gR2 it has JDK and JRE present in it.
    Regards,
    Prakash.

  • How can I see shared pc with firewall set to allow only essential services?

    How can I see shared pc with firewall set to allow only essential services?
    So far if I set it as above then shared does not show up? I have to set the firewall to set access to specific applications and services to get access to my windows based hard drive.
    Cheers
    Mike R

    Ok I solved it myself. Not an ideal solution as I have to connect it manually each time but it will do... Unless anyone has a way to have it auto connect when I start the mac.
    Cheers
    Mike R

  • While updating my iphone 4s to ios6, I had to restore it. Now every time I connect to itunes, I get the "Set Up Your iPhone" window with the set up as new iphone and restore from backup options. After the restore, I got everything except my apps back.

    While updating my iphone 4s to ios6, I had to restore it. Now every time I connect to itunes, I get the "Set Up Your iPhone" window with the set up as new iphone and restore from backup options. After the restore, I got everything except my apps and music back. Do I need to set the phone up as new again?

    Hi Vidbrent,
    If you are having issues updating or restoring your iPhone, you may find the following article helpful:
    Apple Support: If you can't update or restore your iOS device
    http://support.apple.com/kb/ht1808
    Regards,
    - Brenden

  • After creating a new slideshow I export it with the  setting HD 1080p it is then saved as a .mov i then create a dvd in idvd and the quality is not  as good as the original photo's when viewed on the monitor or a TV, am i doing something wrong?

    After creating a new slideshow I export it with the  setting HD 1080p it is then saved as a .mov i then create a dvd in idvd and the quality is not  as good as the original photo's when viewed on the monitor or a TV, am i doing something wrong?

    DVD's are only 640 x 480 (interlaced), so yes, the quality is not nearly as good.  You should probably create your .mov in DV format to best match the DVD format

  • I am still using my Apple G4 1.25 Ghz MDD running Leopard 10.5.8 with iTunes 10.6.3 installed. Can I use an Phone 4s with iOS 5 with this set up? I have read the iPhone iOS 5 user guide and it appears that I can but is anybody actually doing it ?

    Hello to all my readers.I am still using my Apple G4 1.25 Ghz MDD running Leopard 10.5.8 with iTunes 10.6.3 installed. Can I use an Phone 4s with iOS 5 with this set up? I have read the iPhone iOS 5 user guide and it appears that I can but is anybody actually doing it ? My current phone is a £10 Nokia and I've neither wish nor cash to spend more than a grand upgrading to an intel based machine (at the moment) ! Regards to you all.

    If you can find an iPhone running iOS5 and those are the specs for iOS5, there is no reason it should not work.
    If you want a more current version of iOS or a more current device, a Windows computer is always an option at significantly less cost. 
    Granted, there is no requirement to have a computer to use an iPhone.

  • I have 2? How do I sync selected photos from my IPad to my IMac w/o losing all photos on my IPad and getting the phoos o my IMac. ou see I have two IMacs with different sets of photos. Also want to convert all Apple works docs to pages docs on my IMac.

    I have 2? How do I sync selected photos from my IPad to my IMac w/o losing all photos on my IPad which will be replaced with the photos on my IMac.You see I have two IMacs with different sets of photos. Also want to convert all Apple works docs to pages docs on my IMac. Is there and app available to do the former. many thanks. b

    The iPad and related software is designed to sync with only one computer. I suggest transferring the photos from one of your iMacs to the other so that all photos are on one Mac. Same for all other files you want to sync over.
    To get those AppleWorks files to the iPad you'll have to determine if Pages will open them. If it will then use the file sharing feature of iTunes to copy them to Pages on your pad.
    If Pages will not open the AppleWorks files directly you'll have to save them in some format that Pages will read. These include but may not be limited to Pages and Word formats.

  • BO Webi: How to populate a variable with the set of static values for Graph

    Hi All,
    I have the data: Order number, Order Date, processing time coming from the SAP Bex query in the below format:
    Order No    Order Date    Processing time (Days)
    1                 Jan-2011      4
    2                 Jan-2011      5
    3                 Feb-2011      6
    In BO webi report, I have to report the number of orders which were processed in <1day, <2days, <3days,...<10days in a graphical view. i.e., X-Axis:  <1day, <2days, <3days,...<10days(10 static buckets for the processing days)
    Y-Axis: Number of Orders.
    The graphical output should be like below:
    X-Axis: <1day, <2days, <3days,<4days,<5days,<6days,<7days,<8days,<9days,<10days
    Y-Axis: 0, 0,0,0,1,2,3,3,3,3  (count(Order No)) (Cumulative count)
    I am able to calculate the number of orders individually for each of the 10 buckets. But the problem i am facing is that I am not able to hold the 10 static bucket values in a variable to use it for the x-axis in the Graph, as these 10 static bucket values are not coming from the backend source.
    I would like to know if there is way to populate a variable(to use it for the X-Axis in the graph) with the set of 10 static values.
    Any help would be highly appreciated.
    Thanks,
    Leela

    Hi ,
    I think we can use the variable as X-axis in chart.. but Variable Qulaification should be Dimension.
    can you try this?.
    Using efasion universe
    1) Select month and Sold at (unit price) , then run the query
    2) create the variable V_Month ==If [Month]=1 Then "Month1" Else "Month2"  (Note = Variable Qulaification should be Dimension)
    3) Create the variable V_Sum= sum (Sold at (unit price))
    4) create another variable V_Cumulative_Sum==[V_Sum]+Previous([V_Sum])
    Now add V_Month and V_Cumulative_Sum in table , then convert to chart.. now you can add the variable V_Month as X-axis of the chart.
    Hope this will help:)
    Thanks
    Ponnarasu K

  • White lines fixed with art optimization - Is it possible to copy with that setting?

    I've seen threads about the white lines you get on the edges of objects due to the anti-aliasing in Illustrator, and I found that when exporting, you can remove them by setting 'art optimized' in one of the options there.
    For those who don't know the white line issue:
    Sometimes, when Illustrator blends the pixels around an object, it puts a thin white line around it that always appears 1 px thick at any zoom level.
    It's not really there, and when printed it vanishes. Trouble is, even when exporting the document, or copying objects into other software for screen use, it's still there.
    A lot of people think the white line is a tiny gap, but it's not.
    People also tend to tell you it's because you have two objects butted up against one another. This is also not true. The white line still occurs even on overlapping shapes.
    People will also say it's when two shapes on top of each other follow the same path. Again, not true. The white lines still show up even when you only have 1 object following a particular path.
    My issue is that I rarely export an entire document at once, but tend to copy elements of it into Photoshop. When I do so, the white lines travel with it, and become permanent. Even on a .jpg, .png, or .gif image file, the lines are still visible.
    What I want to know is, can I copy objects from Illustrator using art optimization?
    Or is there any other way to copy them without taking those white lines with me?
    I know I can get rid of them by turning anti-aliasing off, but then everything looks really pixellated, so it's not much better.
    Plus, anti-aliasing doesn't actually fix the problem, it just hides it. Even with the setting off, when I copy affected objects to Photoshop, the white lines reappear in Photoshop.
    And please don't bother to reply explaining to me what the white lines are, or how to get rid of them, or how to lose them in exporting. I already know all that.
    Notes:
    I'm running Illustrator CS6
    And Photoshop CS6

    Weirdly, yes. That does work.
    The only problem is that I can't then resize it in Photoshop in the same way as a smart object. I'll just have to know what size it needs to be before I rasterize it.
    But for now, it's a solution that's workable. Thanks! ^.^

  • How to deal with the "Set-Cookie" field in HTTP header??

    I follow the RFC-2616 specification to write a socket program to fetch web pages.
    I have to deal with all the fields included in the HTTP header.
    But the RFC-2616 doesn't talk anything about the "Set-Cookie" field.
    Does anyone know how to handle this field or provide me any useful documentation.
    Any help is appreciated.

    A cookie is set with the "Set-Cookie: "-field in the http header, like this:
    Set-Cookie: mycookie=someValue
    This cookie should only be returned to the same host as it came from, like this in the http header of a request:
    Cookie: mycookie=someValue
    If the parameter looks like this:
    Set-Cookie: mycookie=someValue; path=/cgi-bin
    , the cookie should only be returned to the host if the request path starts with /cgi-bin
    If the parameter looks liek this:
    Set-Cookie: mycookie=someValue; domain=.mydomain.com
    , the cooke should be returned to all hosts in the .mydomain.com-domain
    There is also a "expires="-field, which works as expected and a "secure"-field, which I'm not sure how to handle. Maybe the cookie should only be sent to an SSL-enabled host?
    Hope this helps you. Bye,
    Dag W.

  • Photoshop Elements 13 (Mac) Organizer - Can't save file with version sets.

    I have spent many hours now trying to get Elements Organizer to save Version Sets when I've edited a photo. I've tried more or less every little thing you can find online without any luck. But just moments ago I found that if I move the file to my desktop everything works just fine. I then tried to edit files in a few other folders (also imported to my Organizer) and found that when ever the folder was named to something with a nordic letter in it (å, ä, ö) then I couldn't save my file with version sets (option greyed out) but if I moved that same file to another folder, well then everything worked as it's suposed to.
    I'm using the trial version of PSE 13 for Mac (Yosemite) and the full version is ordered and on it's way. But if this problem can't be fixed, I need to return that order and buy some other photo editing program.
    Can anyone help me with this problem? Is there perhaps a solution to this?
    Please, any help is much appreciated!

    I'm using the English version (as more or less always - Swedish is rarely an option). The thing is that I have never encountered this problem before in any other software I've been using, and certainly not in Aperture that I've been using up until now.
    I name my photo folders with a date and a few words, for ex. "2014-12-31 New Years in Stockholm" (but I normally write in Swedish). I use this method so that my folder that contains the original photos will be easy to find in even without any other software than Finder (or Windows Explorer if I connect my external drive to a Windows machine). I could change the name of all of my folders, or at least all of the folders with a name containing one or more of the letters Å, Ä or Ö to "force" PSE to work as it should, but why? This really shouldn't be a problem.
    I was hoping that their was a simple option or something like that that could fix this issue, but I guess not.
    If this problem lies in the software itself I will have to return it and look elsewhere (but where? Lightroom is certainly not an option if Adobe can't handle "normal" letters and Aperture is discontinued in a few months).
    Thank you for your reply!

  • How to use union statement with declare & set function?

    Hi Experts,
            i  have small query about how to use union statement with declare & set function?
    Example as below :
    DECLARE @name AS date
    Declare @name2  AS date
    /* SELECT FROM [2013].[dbo].[OINV] T0 */
    /* WHERE */
    SET @name = /* T0.DocDate */ '[%1]'
    SET @name2 = /* T0.DocDate */ '[%2]'
    select  '2013',t5.U_salmannm,t1.CardName,t2.sumapplied as CollectionAmount,t2.DcntSum ,t3.DocTotal as InvoiceTotal,
    datediff(dd,t3.DocDate,t1.Docdate) as Days
    from 2013.dbo.orct t1
    inner join 2013.dbo.RCT2 t2 on t1.DocNum = t2.DocNum
    left join 2013.dbo.oinv t3 on
    t3.docentry = t2.baseAbs
    inner join 2013.dbo.ocrd t4 on t1.Cardcode = t4.CardCode
    inner join [2013].[dbo].[@CQ_RTSM] t5 on t4.U_BeatCode = t5.U_RoutCode
    where t2.DcntSum <> 0.000000 and t3.DocDate between [%1] and [%2]
    Union
    /* SELECT FROM [2014].[dbo].[OINV] T0 */
    /* WHERE */
    SET @name = /* T0.DocDate */ '[%1]'
    SET @name2 = /* T0.DocDate */ '[%2]'
    select  '2014',t5.U_salmannm,t1.CardName,t2.sumapplied as CollectionAmount,t2.DcntSum ,t3.DocTotal as InvoiceTotal,
    datediff(dd,t3.DocDate,t1.Docdate) as Days
    from 2014.dbo.orct t1
    inner join 2014.dbo.RCT2 t2 on t1.DocNum = t2.DocNum
    left join 2014.dbo.oinv t3 on
    t3.docentry = t2.baseAbs
    inner join 2014.dbo.ocrd t4 on t1.Cardcode = t4.CardCode
    inner join [2014].[dbo].[@CQ_RTSM] t5 on t4.U_BeatCode = t5.U_RoutCode
    where t2.DcntSum <> 0.000000 and t3.DocDate between [%1] and [%2]

    You have to create stored procedure in SQL only .
    Like u must have create for Crystal .
    You can execute procedure in query manager but you have to enter parameter manually..
    example
    Exec @Test '20140101' '20140501'
    Every time user has to enter it manually in yyyymmdd format in case of date parameters.
    Example
    Create Proc [@Test]
    as begin
    DECLARE @name AS date
    Declare @name2  AS date
    /* SELECT FROM [2013].[dbo].[OINV] T0 */
    /* WHERE */
    select  '2013',t5.U_salmannm,t1.CardName,t2.sumapplied as CollectionAmount,t2.DcntSum ,t3.DocTotal as InvoiceTotal,
    datediff(dd,t3.DocDate,t1.Docdate) as Days
    from 2013.dbo.orct t1
    inner join 2013.dbo.RCT2 t2 on t1.DocNum = t2.DocNum
    left join 2013.dbo.oinv t3 on
    t3.docentry = t2.baseAbs
    inner join 2013.dbo.ocrd t4 on t1.Cardcode = t4.CardCode
    inner join [2013].[dbo].[@CQ_RTSM] t5 on t4.U_BeatCode = t5.U_RoutCode
    where t2.DcntSum <> 0.000000 and t3.DocDate between @Name and @Name2
    Union
    /* SELECT FROM [2014].[dbo].[OINV] T0 */
    /* WHERE */
    select  '2014',t5.U_salmannm,t1.CardName,t2.sumapplied as CollectionAmount,t2.DcntSum ,t3.DocTotal as InvoiceTotal,
    datediff(dd,t3.DocDate,t1.Docdate) as Days
    from 2014.dbo.orct t1
    inner join 2014.dbo.RCT2 t2 on t1.DocNum = t2.DocNum
    left join 2014.dbo.oinv t3 on
    t3.docentry = t2.baseAbs
    inner join 2014.dbo.ocrd t4 on t1.Cardcode = t4.CardCode
    inner join [2014].[dbo].[@CQ_RTSM] t5 on t4.U_BeatCode = t5.U_RoutCode
    where t2.DcntSum <> 0.000000 and t3.DocDate between
    between @Name and @Name2
    end

  • How to use addAll with a set of integers in array

    Hi does anyone know how to use void addAll (Set other) with a set of integers?...i want to add all of the integers from the other set to this one. For example, if i have this set {4, 9, 2} and I wanted to add to it all of the integers from another set {3, 2, 8, 4}, the set becomes {4, 9, 2, 3, 8}. I'm stumped on how to do this..if anybody could help, thanks!

    Set1 = ...
    Set2 = ...
    Set1.addAll(Set2);
    addAll(Collection<? extends E> c)
    Adds all of the elements in the specified collection to this set if they're not already present (optional operation). If the specified collection is also a set, the addAll operation effectively modifies this set so that its value is the union of the two sets. The behavior of this operation is unspecified if the specified collection is modified while the operation is in progress.

  • Problem with subform set

    Hi all ,
    I am facing a problem with subform set. When i use two subform sets with same set of conditions in a form, only the first subform set works while the second one does nothing. Did any of you faced the same problem ? If so Please let me know the solution you came up with. Thanks.
    SrPrabhu

    Hi scott,
    The problem is with subform set and not subform. In subform set, we can give conditions to make only one subform visible at a time that satisfies the condition. First create a subform set having more than one subform. Now apply the conditions to that subform set. Check if it works. I m sure it wil work. Now just make a duplicate copy of the same subform set. Place it in the same form so that now two subform sets are available. Now preview the form. U wil fine only one subform set working and the other one doesnt.
    We can use any number of subform set within a form. If different conditions are applied to each subform set , it works fine.
    i wonder now wat wud u do in case if we are in need of two subformset having the same condition in a form ?
    Thanks,
    Sr Prabhu

  • Can different music be used with different set of photos in a slide show?

    Can different music be used with different set of photos in a slide show?

    Yes. The basic idea is that you make a playlist of songs and choose that to use with the slideshow, rather than any particular song. In iPhoto 11 you can do this in iPhoto. In earlier versions you do this in iTunes.
    There is a limitation. Each song will play the full way through, you can't croassfade from one to another and so on.
    Alternatives to iPhoto's slideshow include:
    iMovie, on every Mac sold.
    Others, in order of price: PhotoPresenter  $29
    PhotoToMovie  $49.95
    PulpMotion  $129
    FotoMagico $29 (Home version) ($149 Pro version, which includes PhotoPresenter)
    Final Cut Express  $199
    It's difficult to compare these apps. They have differences in capability - some are driven off templates. some aren't. Some have a wider variety of transitions. Others will have excellent audio controls. It's worth checking them out to see what meets your needs. However, there is no doubt that Final Cut Express is the most capable app of them all. You get what you pay for.

Maybe you are looking for