Why this simple assingment is not possible in Generics ?

Hi
Just curious to know why this simple conversion does not work and requires casting ?
List<? super Integer> list = new ArrayList<Integer>();
List<? super Number> listN = list; //Requires Casting
List<? extends Number> listExNu = new ArrayList<Number>();
List<? extends Integer> listExIn = listExNu; //Requires CastingAs per my understanding ,
A List<? super Number> can fit inside a List<? super Integer> ...
So what really happens here to force casting ? Any ideas ?

ejp wrote:
List<? super Integer> list = new ArrayList<Integer>();The only two classes that are superclasses of Integer are Number and Object.Not quite. Please note that the clause *? super Integer* is inclusive, i.e. it also matches List<Integer>.
Additionally, it matches all interfaces implemented by Integer. Thus, the following types can be assigned to list:
List<Integer>
List<Serializable>
List<Comparable<Integer>>
List<Comparable<? extends Integer>>
List<Comparable<? super Integer>>
List<Comparable<? extends Number>>
List<Comparable<? extends Serializable>>
List<Comparable<?>>
List<Number>
List<Object>And the following types can be assigned to listN:
List<Serializable>
List<Number>
List<Object>Since the latter is a genuine subset of the former, an implicit conversion such as listN = list is impossible.

Similar Messages

  • I don't understand why this simple program will not print.  Help please!!!

    This program runs with no errors, it just doesn't print anything. Anyone have a clue as to why it doesn't print anything?
    Here is my code:
    import javax.swing.JOptionPane;
    public class Converter {
    public static void main(String[] args) {
    int a,b,c;
    int inputNum=Integer.parseInt(JOptionPane.showInputDialog(null," Enter a length in yards: "));
    String measurement = JOptionPane.showInputDialog(null,"Enter the unit of conversion (inches, feet, or centiyards): ");
    if (measurement == "inches"){
    a = inputNum*36;
    System.out.println(a + "inches");
    else if (measurement == "feet"){
    b = inputNum*3;
    System.out.println(b + "feet");
    else if (measurement == "centiyards"){
    c = inputNum*100;
    System.out.println(c + "centiyards");
    }

    Don't confuse String's equals() method with the equality operator '=='. The == operator checks that two references refer to the same object. If you want to compare the contents of Strings (whether two strings contain the same character sequence), use equals(), e.g. if (str1.equals(str2))...
    Example:String s1 = "foo";
    String s2 = new String("foo");
    System.out.println("s1 == s2: " + (s1 == s2)); // false
    System.out.println("s1.equals(s2): " + (s1.equals(s2))); // trueFor more information, check out the Java FAQ
    ~

  • When I connect my iPhone 5 to my laptop and iTunes, I can't play movies from the iPhone on my computer.Why is that? Can I do this or it's not possible with iPhone5? With my iPod it's no problem.

    When I connect my iPhone 5 to my laptop and iTunes, I can't play movies from the iPhone on my computer.Why is that? Can I do this or it's not possible with iPhone5? With my iPod it's no problem.

    Reinstall iTunes. Make sure you follow the instructions in this support document to the letter. http://support.apple.com/kb/HT1923.
    You may have some problems because Apple has not certified that everything works with Windows 8 yet.

  • Why is this simple PDF file not searchable?!? Someone please help!!

    Hi all!
    I DESPERATELY need to figure out why this PDF file is not searchable, and how to fix it. It's from a teacher of mine at my university, and basically I want to be able to make all of the PDF's she gives out searchable since there is a lot of content. I'm running Adobe Reader 11, ver. 11.0.10, on an early 2014 Macbook Air running OS X Yosemite ver. 10.10.1. I've tried using the search function, the advanced search function, and I've looked for the option to turn OCR on (couldn't find it)....and none of these attempts have resolved the issue.
    The weird thing about this is I've NEVER had a problem searching thru ANY PDF on this Mac -- including really, really complex lecture PDFs from other professors -- so I can't figure out why these are any different. Is it because this PDF was exported out of a Powerpoint presentation (I think)? Or something else? Does anyone have any ideas?
    Lastly, I'm attaching a screenshot (below) so that if any of you give me any directions ("Look under the [such and such] toolbar"), you can see first exactly what I see.
    THANKS guys for any input and consideration!
    -R

    There are some issues with this PDF file.  It's not tagged but even still it has some real problems.  I checked the file to see what created it and it was something called "Wine Postscript Driver" and the PDF Producer was "GPL GhostScript 9.10"  When you check the file in Preflight then you will begin to understand that this is a poorly created PDF file.  Here is a bit of the PDF Syntax report:

  • Why this simple inheritance issue occour

    public class A extends B
         private Object lock=null;
         public A()
              super();// super intiallized
    Err:          lock=super; //givin error on this statement
    i m getting on above Err statement Error is
    '.' expected at line 57 (57:28)
    why is so is it not possible to assign super class to some other class in subclass
    how to solve this problem .and why it occour
    i also try this statement as
    lock=(Object)super;
    but same error occours
    Thanks

    super doesn't work like you would expect it to in the case of assignment. super isn't a reference to an object, but rather a mechanism for accessing inherited methods or fields.
    Try using the following
    lock = super.clone();Cheers,
    Cypher

  • Resetting this reverse document is not possible - FBRA

    Hi,
    I'm trying to reset the cleared items with Tcode FBRA also system is throwing error like below
    ==================================================================================================
    Resetting this reverse document is not possible
    Message no. F5579
    *Diagnosis
    The system required a reverse document to be created after resetting a clearing procedure as otherwise documents would have been generated in the system which could not have been processed correctly. The following cases require the clearing document to be reversed:*
    Exchange rate differences were posted.
    =================================================================================================
    the document has items of exchange rate differences, but,
    Question: The exchange rate difference it's related with t-code  fagl_fc_val ???l

    Hi,
    Reverse the document using FB08 and input the reversal document no in the reset transaction FBRA.
    Hope it works.
    ~Andrew

  • Why this character \ it is not working in action scrip?

    Hi...
    Why this character \ it is not working in action scrip? And
    how can I solve it?
    on (release) {
    text.text = text.text + "l"
    Please your help ASAP
    thank you

    yea, that's true, but I don't think that is the problem.. I
    use it every once in a while, and it doesn't break the script.
    "I’m trying to make bush button if i press it, the
    action script it well write the text in text area and I’m
    using Flash MX 2004"
    This statement makes
    zero sense.. please clean it up and make it understandable,
    and tell what version of Actionscript you are publishing to.

  • Why this Verisign certificate is not automatically recognized ?

    Hello,
    We used java and JSSE to acces an https URL, with a 64 bit certificate, it's ok.
    We try to use the new certificate 128 bit, it's KO.
    We need to declare this new certificate with keytool in a keystore, and to add in the java program the reference to the keystore file.
    Is it normal, why this new certificate is not automatically recognized in the cacerts ?
    thanks for your response.
    ******* Old certificate ********************
    Record ID: 14
    Issuer Record ID: 4
    Trusted: Yes
    Version: 1
    Issuer name: Secure Server Certification Authority
         RSA Data Security, Inc.
         US
    Public key algorithm: rsaEncryption
    Public key size: 1024
    Signature algorithm: md5WithRsaEncryption
    Issuer unique ID: None
    Subject unique ID: None
    Number of extensions: 0
    ******* New Certificate *************************
    Record ID: 14
    Issuer Record ID: 0
    Trusted: Yes
    Version: 3
    Issuer name: www.verisign.com/CPS Incorp.by Ref. LIABILITY LTD.(c)97
    VeriSign
    VeriSign International Server CA - Class 3
    VeriSign, Inc.
    VeriSign Trust Network
    Public key algorithm: rsaEncryption
    Public key size: 1024
    Signature algorithm: md5WithRsaEncryption
    Issuer unique ID: None
    Subject unique ID: None
    Number of extensions: 4
    *****************************

    Hi,
    we had the some problem.
    The new certificate is Class 3 Version 3, but in the cacerts file is present only the Version 1.
    The first solution was been to include our certificate in cacerts file and redistribute the cacert file to our clients (or click always in the alert pop-up). ORRIBLE!
    The finally solution (i hope) is to set up correctly the web-server.
    We have Apache 1.3.27 + mod-ssl. The installation of certificates has involved the only authenticated certificate file and private key. By the way there's another file that is not in use by default: the intermediate.crt file (in httpd.conf is indicated by tag SSLCACertificateFile). The intermediate.crt is distribuited by Verisign and it must be installed to solve the problem.
    The difference is visible in Mozilla browser too.
    I
    Best Regards.
    Rosas!!

  • Why this candlestick Chart does not returns an URL as a link ?

    Hi,
    I have done a nice Candlestick Flash Chart. But The problem is that the link does not work. When I click on a point - the cross -, nothing happens, which means the URL is not displayed in the URL zone of the navigator - I am under Firefox. I have been using this technique on other charts (2D Column) and it was working nicely. I don't see why it is not working in the Candlestick type chart. I have been outputting the result of the PL/SQL into an item to check if the SLQ generated by the PL/SQL function was coorect and tested it under SQL Developper and I do get good results and nices URLS under SQL Developper. Thus is why i don't understand why this is not working here.
    DECLARE
    X VARCHAR2 (4000);
    BEGIN
    x := 'SELECT
    ''f?p=&APP_ID.:8:&SESSION.:GET_DETAIL_MONTH:NO::P8_MONTH:''
    ||TO_CHAR(TRUNC(DATE1, ''MM''), ''MM/YY'') LINK,
      TO_CHAR(TRUNC(DATE1, ''MM''), ''MM/YY'') LABEL,
      AVG(VALEUR) OPEN,
      MAX(VALEUR) HIGH,
      MIN(VALEUR) LOW,
      AVG(VALEUR) CLOSE FROM EVV_'|| UPPER (:p184_ename) ||
    ' WHERE CLEF_VAR = (SELECT CLEF_VAR FROM SITE_ECHELLE WHERE SITE = '''
    || UPPER (:p184_ename) ||
    ''') AND DATE1 BETWEEN TO_DATE (''01/01/'
    ||:P8_YEAR||'000000'', ''DD/MM/YYYYHH24MISS'') AND TO_DATE (''31/12/'
    ||:P8_YEAR||'235959'', ''DD/MM/YYYYHH24MISS'')
    GROUP BY TRUNC(DATE1, ''MM'')
    ORDER BY TRUNC(DATE1, ''MM'')';
    RETURN (X);
    END;Example of SQL generated by the above function :
    SELECT 'f?p=12400:8:1473118156348570:GET_DETAIL_MONTH:NO::P8_MONTH:'
    ||TO_CHAR(TRUNC(DATE1, 'MM'), 'MM/YY') LINK,
    TO_CHAR(TRUNC(DATE1, 'MM'), 'MM/YY') LABEL ,
    AVG(VALEUR) OPEN,
    MAX(VALEUR) HIGH,
    MIN(VALEUR) LOW,
    AVG(VALEUR) CLOSE
    FROM EVV_E007
    WHERE CLEF_VAR =
    (SELECT CLEF_VAR FROM SITE_ECHELLE WHERE SITE = 'E007'
    AND DATE1 BETWEEN TO_DATE ('01/01/2006000000', 'DD/MM/YYYYHH24MISS') AND TO_DATE ('31/12/2006235959', 'DD/MM/YYYYHH24MISS')
    GROUP BY TRUNC(DATE1, 'MM')
    ORDER BY TRUNC(DATE1, 'MM')
    Example of output of the link :
    f?p=12400:8:1473118156348570:GET_DETAIL_MONTH:NO::P8_MONTH:01/06     f?p=12400:8:1473118156348570:GET_DETAIL_MONTH:NO::P8_MONTH:02/06     
    Thank you for your kind answers !

    Hello Christian,
    I first thought that your url shouldn't contain / (in your month format - better to use a dash -).
    But then I remembered the Candlestick chart that is standard in APEX is having a bug.
    I did a quick test here: http://anychart.apex-evangelists.com/pls/apex/f?p=454:8:0::NO:::
    On the left you see the default chart in APEX (based on Anychart 3.3), if you click on the candle it doesn't show hello. If you click on the right chart it does.
    The right chart is based on Anychart 5 and makes use of our integration kit.
    Regards,
    Dimitri
    http://dgielis.blogspot.com/
    http://www.apex-evangelists.com/
    http://www.apexblogs.info/
    REWARDS: Please remember to mark helpful or correct posts on the forum

  • Why this simple IF - ENDIF is NOT working??

    Hi Experts,
    Am wrting a simple  IF condition with WILD CARD value , in the user exit, as below,
    if xlikp-lgbzo = 'AB'. (pls. notice that, there is WILD CARD in the 'AB' value)
    sy-subrc = 0.
    else.
    sy-subrc = 4.
    endif.
    1) Say, the XLIKP-LGBZO value = AB-01-02 (pls. notice that, there  ' - ' in the value of AB-01-02)
    then, sy-subrc is becoming 4 ?????????????
    2 )Say, the XLIKP-LGBZO value = ZB-01-02
    then, sy-subrc is becoming 4
    the 2nd case is OK, but, Why the 1st case is becoming FALSE?? actuallym it shuld b TRUE, right??
    Is it bcoz of hiphans -  " - "?? but, i tried with WITH OUT hiphans , then also NOT working CORRECTLY??
    thanq

    Hi Srini,
    Try the following:
    IF XLIKP-LGBZO  CP 'AB*'.
    sy-subrc = 0.
    ELSE.
    sy-subrc = 4.
    ENDIF.
    CP - Contains Pattern
    Hope this helps you.
    Regards,
    Chandra Sekhar

  • Why this simple 'IF' syntax is not working?

    Hello
    Pls. help me that,
    var myObject = /TextField11/
    var greyFieldsList = "TextFieldAA TextFieldBB TextFieldCC "
    var ReqFieldsList = "TextField11 TextField22 TextField33 "
    var returnValue = greyFieldsList.search(myObject);
    var returnValueReq = ReqFieldsList.search(myObject);
    if (returnValue != -1) {
    this.fillColor = "192,192,192"; //GREY
    this.access    = "readOnly";
    else if (returnValueReq != -1)
    this.fillColor = "255,255,191";  //YELLOW
    else
    // do nothing
    Yellow is not working at all!!
    Grey is working some times, some times not!
    Pls. correct my IF condition in such a way it shoud work.
    At given point of time, any field possess only one color
    Thank you

    Hi Srini,
    Try the following:
    IF XLIKP-LGBZO  CP 'AB*'.
    sy-subrc = 0.
    ELSE.
    sy-subrc = 4.
    ENDIF.
    CP - Contains Pattern
    Hope this helps you.
    Regards,
    Chandra Sekhar

  • Simple? can anyone tell why this simple btn doesn't work?

    Trying to write my own simple disabling button class (with
    some help from friend - thanks LuigiL)
    So, why does my button not turn off when clicked? it runs the
    deinitializeBehavior function but the removeEventListeners are not
    actually being removed...
    I don't know why but could this possibly be a graphics issue?
    Thanks in advance

    HAH! OK - I am starting to get this a little.
    Thank you St. LuigiL. You are my Obie-wan: the force is
    strong with you.
    I made a Main.as document class and now the whole thing works
    like a charm! I was wondering if it was necessary to do so - and it
    was.
    In my OCD I am constantly striving to keep my classes to a
    bare minimum (if I could write everything on one page I would.)
    I very much appreciate your incredible help and support.
    BAM

  • Why this removeChile function can not work

    Dear All
    can any one help me fix this problem? i can not delete one job record from XML file, and there is no any error message, don't know why can not remove the node from XML file. Thanks!
    XML File:
    <Job_ad>
    <job>
    <title>ABC
    <detail>123
    </job>
    </job_ad>
    the Java code
    try {
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder parser = factory.newDocumentBuilder();
    File fn = new File(fileName);
    Document doc = parser.parse(fn);
    NodeList ReportDate = doc.getElementsByTagName("job_ad");
    NodeList job = doc.getElementsByTagName("job");
    for (int i = 0; i < job.getLength(); i++) {
    Element jobDetail = (Element)job.item(i);
    String jobTitle = jobDetail.getElementsByTagName("title").item(0).getFirstChild().getNodeValue();
    if (jobTitle.equals("ABC")) {
    System.out.println("record found");
    Node deadElement = (Node)jobDetail.getParentNode().removeChild(jobDetail);
    catch (Exception e) {
    System.out.println(e);

    if (jobTitle.equals("ABC"))The actual value of jobTitle is "ABC\n", if your posted XML is accurate. You forgot to account for the new-line character after the text.
    A little debugging (such as System.out.println(jobTitle)) might have told you that.

  • What does this simple folder action not work?

    OK I have been playing with this all weekend. I just wanted a simple folder action to move a file from folder a to folder b. There is really not much to it. The workflow works just fine. "Somtimes" running the script runs the workflow.app. However when I drop a file into folder a - nothing happens. I have enabled folder actions. Can anyone help?
    here is a pic of the relative screens that should help you.
    http://flickr.com/photos/hawsnet/2605303472/sizes/l/
    Thanks for any help you can provide.
    PS I even stopped by my local Genius Bar -- they could not help.

    Vantive,
    Try either:
    *on adding folder items to this_folder after receiving added_items*
    *tell application "Finder"*
    *repeat with this_item in added_items*
    *move this_item to folder "Folder B" of folder "Desktop" of folder¬*
    *"MyShortName" of folder "Users" of the startup disk*
    *end repeat*
    *end tell*
    *end adding folder items to*
    Or:
    *on adding folder items to this_folder after receiving added_items*
    *tell application "Finder"*
    *repeat with this_item in added_items*
    *move this_item to "Macintosh HD:Users:MyShortName:Desktop:Folder B"*
    *end repeat*
    *end tell*
    *end adding folder items to*
    In either case replace MyShortName with your actual short name. +Make sure the script is saved to your Home/Library/Scripts/Folder Action Scripts folder.+ Then right-click or control-click on "Folder A" and, if necessary, select "Enable Folder Actions." If enabled, right-click or control-click on "Folder A" and select "Attach a Folder Action…" When the Choose-a-File window appears highlight the script and press Choose.
    Both of the above scripts worked for me in testing. For what it's worth, both my /Library/LaunchAgents, and /System/Library/LaunchAgents folders are empty.
    Good Luck...
    Regards, Andrew99

  • Any ideas why this "if" statement is not working?

    I have this code inside a click command. The first part works, will change variable to 5. But if variable = 5 animation does not play: 
    if (position != "5"){
                                  sym.setVariable("position", "5");
                                  var position = sym.getVariable("position");
                                            sym.$("Text3").html(""+position);
    else if(position==5)
    sym.play("animation")
    Thanks

    Hi there, can you put a console log before the if statement to confirm that you have a valid value for the "position" variable, at that click scope?
    console.log('position = '+position);
    Run it in your browser and open the JS console to check the log output of the above test.

Maybe you are looking for

  • Approval workflow error when creating a new custom entity in FIM 2010 R2

    Hello, i'm hoping somebody here can help, me i've been struggling with this for some time now. On a fresh FIM installation i create a custom entity named "Role" and add a few custom attributes. I then create an approval workflow and MPR for normal us

  • Hp Pavilion Dv6 3153si - Recovery Discs

    Hi. Can anyone please help me with recovery discs for Hp Pavilion Dv6 3153si. On Hp's site you can order discs but not for this specific model. I had harddrive issues and had do do a complete format. As you all know the recovery was supplied on the h

  • Language changed

    Language changed and I can't change it back

  • Wireless keyboard will not enter discoverable mode

    Hi, Changed the batteries on my bluetooth apple keyboard and now the keyboard won't pair with the iMac; nor will it enter "discoverable" mode (when I press the keyboard power button the keyboard light illuminates green for about a second and then goe

  • Can NOT update my website (Golive 4)

    Im a Mac user. My server is itsamac is golive 4 just too old? or is it something else