Why the following doesn't compile

Can someone explain me why the following doesn't compile:
class A<N extends Number> {
    public LinkedList<String> list;
    public N getN() {
        return null;
class Test {
    Test(A a) {
        Number n = a.getN();
        String str = a.list.getFirst();
}The compiler error is:
incompatible types
found   : java.lang.Object
required: java.lang.String
        String str = a.list.getFirst();And if compiler "lose" generic info for some reason or other, so it don't know type "a.list.getFirst()" anymore and think that it's Object, then why it know type of "a.getN()"?

DrClap wrote:
I'm not convinced by that explanation. I've used List<Whatever> in classes which aren't themselves generic and it works as I and the OP expect it to work. And I don't really see the difference between a class which isn't generic and a class which could be generic but isn't. I also don't see why public members should be treated differently when accessed from outside a class compared to when accessed inside a class.
If it indeed doesn't compile (and I haven't tested that myself) then no doubt there's a reason for that, this isn't one of those convoluted examples which the compiler writers could have missed without anybody noticing. It just doesn't seem to me that what jtahlborn wrote is actually the reason.Jtahlborn was correct with his explanation: whenever you use a generic type as the corresponding "raw type", the type loses all its generic features.
Thus, the public member "list" loses its parameter of type String and becomes the raw type "List"
The method "getN" loses its return type +"N extends Number"+ and yields simply a "Number".
For a detailed discussion, see [http://java.sun.com/docs/books/jls/third_edition/html/typesValues.html#110257]

Similar Messages

  • Why the preloader doesn't work in IE 8 but works in FireFox?

    Why the preloader doesn't work in IE 8 but works in FireFox?
    Please see the attached files.  Thanks in advance.

    Why doesn't the preloader work in IE8?
    What's "virtual sandbox"?

  • Why the imsg doesn't work without a sim card with iOS 7???

    Why the imsg doesn't work without a sim card with iOS 7???

    If it worked for you using iOS 6, then it appears iOS 7 has made some changes.  Was it working before?

  • Why the following command cannot run successfully?

    Why the following command cannot run successfully?
    SQL> exec DBMS_SPM.EVOLVE_SQL_PLAN_BASELINE;
    BEGIN DBMS_SPM.EVOLVE_SQL_PLAN_BASELINE; END;
    ERROR at line 1:
    ORA-06550: line 1, column 7:
    PLS-00306: wrong number or types of arguments in call to
    'EVOLVE_SQL_PLAN_BASELINE'
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored

    Here is an example how you can invoke it:
    SET SERVEROUTPUT ON
    SET LONG 10000
    DECLARE
        report clob;
    BEGIN
        report := DBMS_SPM.EVOLVE_SQL_PLAN_BASELINE(
                      sql_handle => 'SYS_SQL_593bc74fca8e6738');
        DBMS_OUTPUT.PUT_LINE(report);
    END;
    /With kind regards
    Krystian Zieja
    http://www.projectenvision.com

  • Hi there, i have a ipod nano general 7, just used one year. Now can't charge battery. When charging, the icon shows full power, but disconnect it. It becomes dark, no power. Why, the battery doesn't work ?

    I've a ipod nano general 7, I've just used it one year. Now, I can't charge the battery. When charging, the icon shows full power. But when I disconnect, the ipod becomes dark, no power is keeped. Why, the battery doesn't work ? the life of my ipod's battery is too short ? 

    Howdy tamsg,
    Welcome to Apple Support Communities.
    The article linked below provides a lot of great troubleshooting tips that can help you resolve the issue with your iPod nano charging or displaying a blank black screen.
    iPod nano (7th generation): Hardware troubleshooting - Apple Support
    So long,
    -Jason

  • Why the following error message "The message could not be moved to the mailbox Trash".

    Why do I see the following error message?
    "Unable to Move Message. The message could not be moved to the mailbox Trash".

    Try closing the Mail app via the multitasking bar and see if you can delete them when you re-open the app : double-click the home button to open the taskbar and then swipe or drag the Mail app's 'screen' up and off the top of the screen to close it, and click the home button to close the taskbar.
    If that doesn't fix it then try going into Settings > Mail, Contacts, Calendars. Then select the account on the right-hand side of that screen, select Account, then Advanced, Deleted Mailbox, and under On The Server tap the 'Trash' folder so that it gets a tick against it - then come out of that series of popups by tapping on the relevant buttons at the top of them and then see if you can delete emails.

  • Why the wifi doesn't work after the upgrade to iOS 5?

    The problem is that after the upgrade to iOS 5 the wifi doesn't work. I mean, iPad is connected to the wifi but not to the internet and also the connection on the other device doesn't work. So I had to turn off the router and then turn it on.

    Try a hard reset first to see if that does any good.  To do this, press and hold both the Sleep/Wake and Home buttons together long enough for the Apple logo to appear.
    If no luck with that, you'll need to manually connect your iPod to your iTUnes library in recovery mode using the instructions in the Apple support document below. Doing so will allow you to bypass the passcode and restore the iPod.
    iOS: Unable to update or restore
    B-rock

  • Why the select doesn't run?

    Hi
    I have the following select in a function containing in a function group.
    SELECT SINGLE makt-maktx FROM makt WHERE makt-matnr = matnum.
    I have declare in the topinclude Tables: makt but I still get the syntax message:
    Unknown column name "MAKT-MAKTX". not determined until runtime, you cannot specify a field list.          
    Can anybody help

    hi check this...
    tables: makt .
    data: begin of itab1 occurs 0,
          matnr like mara-matnr,
          maktx like makt-maktx,
          end of itab1 .
    select-options:s_matnr for makt-matnr.
    select single matnr maktx  from makt
             into  itab1
             where matnr in s_matnr .
    append itab1 .
    loop at itab1 .
    write:/ itab1-matnr,
            itab1-maktx.
    endloop.
    regards,
    venkat.

  • Why my app doesn't compile when my NSFetchedResultsController properties is named "fetchedResultsController" and I override the setter selector?

    Hi everyone,
    I'm struggling with a problem here. I cannot compile my app when I name a NSFetchedResultsController "fetchedResultController" and I override the setter selector.
    How do you explain that? Is it a bug?
    I'm using xCode Version 5.0.2 (5A3005) on OS X 10.9 (13A603).
    Here is a sample of code showing the problem:
    TestViewController.h
    #import <UIKit/UIKit.h>
    @interface TestViewController : UIViewController
    @end
    TestViewController.m
    #import "TestViewController.h"
    @interface TestViewController ()<NSFetchedResultsControllerDelegate>
    @property (strong, nonatomic) NSFetchedResultsController *fetchedResultsController;
    @end
    @implementation TestViewController
    -(void)setFetchedResultsController:(NSFetchedResultsController *)fetchedResultsController
        if(_fetchedResultsController) _fetchedResultsController.delegate = nil;
        _fetchedResultsController = fetchedResultsController;
    - (NSFetchedResultsController *)fetchedResultsController
        if (!_fetchedResultsController) // if no filter, no request
            static NSString *SomeCacheName = @"SomeCache";
            NSFetchRequest *request = [[NSFetchRequest alloc] init];
            [request setRelationshipKeyPathsForPrefetching:@[@"tags",@"tags.tagged_players"]];
            [NSFetchedResultsController deleteCacheWithName:SomeCacheName];
            _fetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:request managedObjectContext:[NSManagedObjectContext defaultContext] sectionNameKeyPath:nil cacheName:SomeCacheName];
            NSError *error;
            ZAssert([_fetchedResultsController performFetch:&error], @"Event list fetch error. %@. %@", error, error.userInfo);
            _fetchedResultsController.delegate = self;
        return _fetchedResultsController;
    @end

    You have custom accessor methods so need to explicitly declare the instance variable _fetchedResultsController. Read this note under You Can Implement Custom Accessor Methods in Programming with Objective-C.
    https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/Programmi ngWithObjectiveC/EncapsulatingData/EncapsulatingData.html
    Note: The compiler will automatically synthesize an instance variable in all situations where it’s also synthesizing at least one accessor method. If you implement both a getter and a setter for a readwrite property, or a getter for a readonlyproperty, the compiler will assume that you are taking control over the property implementation and won’t synthesize an instance variable automatically.

  • Why the Finder doesn't make diefference between CS3 illustrator .eps and CS3 Photoshop .eps when I double click on a file?

    The finder used to make difference between Illustrator ans Photoshop .eps files except sometomes when these files came from a Windows PC, but now it doesn't work anymore and all .eps files are considereds as Photoshop .eps files.
    How can I revert to original default settings?
    Thanks. :-)

    Prior to Snow Leopard, Mac OS actually remembered what app created a file, and used that app when you double-clicked a file.  Now, Snow Leopard goes entirely by the suffix, modified by any particular settings you have made for that file in Get Info.
    If you want to recreate the old behavior, there is a third-party package called LaunchCodes that claims to do this.
    More information about the removal of the creator code here:
    http://www.cultofmac.com/how-snow-leopard-ditched-creator-codes-and-why-it-matte rs/15928

  • Why the script doesn't work

    I installed solaris 8 and got a problem. I can use unix commands like ls, mkdir, cp, mv,.... But when I created a script and try to run it, I got the message says "That command doesn't exist." I check the persion and owner, they are OK. Also I use admintool to add a user, I try to put a user's home directory /usr/eric/, when I submit it, I got message "don't have permission" (I am a super user). When I exit from admintool and check /etc/passwd file, that user is already there.
    anyone response is appreciate.

    Hi,
    Is your PATH variable set to point to the directory
    which has this script ?
    Set the PATH variable and try (if itis not already set).
    Pls follow the steps below:
    o In your shell, set the environment variable PATH as:
    On Bourne/Korn shell:
    #PATH=/usr/bin:/usr/sbin:.
    On C-shell:
    %setenv PATH /usr/bin:/usr/sbin:.
    Append (with a ":" prefix) the directory having your script to the
    above PATH variable.
    You can make this change permanent by having this variable set
    through your ".profile" file for sh and ksh, and ".cshrc" for
    csh (in your home directory).
    Please refer to man pages of login(1) for more information.
    Thanks,
    Gopinath.
    Sun - DTS.

  • Who knows why the "repaint()"doesn't work when ....?

    I use a "while(threadgroup.activeCount()!=0){} "to block the sentence below
    from being excecuted before I finish the thread above, however since this "while"
    the repaint() in the thread above doesn't work , but I have evidence that the thread
    is really going on ( I use Sytem.out.print() to prove this)

    I'm not sure I follow. Try providing a snippet of the relevant code, and we'll see if anybody on the forum can figure it out for you.

  • Please help -- Why the applet doesn't run with jre1.4.1_01?

    Hi,
    I have an applet embedded in a remote-server page. It can be loading from the server and running in the local computer with Jre1.3.1. After I uninstalled jre1.3.1 and installed JRE1.4.1_01. My applet doesn't run. Here is the message from Java Consol:
    java.lang.NullPointerException
    at sun.plugin.cache.CachedFileLoader.writeHeaders(Unknown Source)
    at sun.plugin.cache.CachedFileLoader.createCacheFiles(Unknown Source)
    at sun.plugin.cache.CachedFileLoader.access$200(Unknown Source)
    at sun.plugin.cache.CachedFileLoader$3.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.plugin.cache.Cache.privileged(Unknown Source)
    at sun.plugin.cache.CachedFileLoader.download(Unknown Source)
    at sun.plugin.cache.CachedFileLoader.load(Unknown Source)
    at sun.plugin.cache.FileCache.get(Unknown Source)
    at sun.plugin.net.protocol.http.HttpURLConnection.connectWithCache(Unknown Source)
    at sun.plugin.net.protocol.http.HttpURLConnection.connect(Unknown Source)
    at sun.plugin.net.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.getHeaderField(HttpURLConnection.java:1197)
    at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:247)
    at sun.applet.AppletClassLoader.getBytes(AppletClassLoader.java:250)
    at sun.applet.AppletClassLoader.access$100(AppletClassLoader.java:42)
    at sun.applet.AppletClassLoader$1.run(AppletClassLoader.java:143)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.applet.AppletClassLoader.findClass(AppletClassLoader.java:140)
    at sun.plugin.security.PluginClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
    at sun.applet.AppletClassLoader.loadClass(AppletClassLoader.java:114)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
    at sun.applet.AppletClassLoader.loadCode(AppletClassLoader.java:501)
    at sun.applet.AppletPanel.createApplet(AppletPanel.java:566)
    at sun.plugin.AppletViewer.createApplet(Unknown Source)
    at sun.applet.AppletPanel.runLoader(AppletPanel.java:495)
    at sun.applet.AppletPanel.run(AppletPanel.java:292)
    at java.lang.Thread.run(Thread.java:536)
    I copy the my html file which has this applet built-in to my local computer. The webpage can be openned and the applet running fine even with jre1.4.1. Why it didn't run with Jre1.4.1 and it did run with jre 1.3.1 when loading remotely? Could someone tell me what the above messages mean? Is this a bug from Jre1.4.1_01?
    I have running server at 206.29.25.29. and select "read sensor". Jre1.4.1_01 will not let the applet run, but jre1.3.1 does.
    Is there any body know about this issue?
    Thanks,
    Kunlun

    In fact, I have run many tests and the only failures are when the plugin is 1.4.2 and the app server is on Unix:
    Build      Deploy      Build JDK     PlugIn JDK     App Server JDK     Result
    Win     Win     1.4.2_02     1.4.2          1.4.2          Success
    Win     Win     1.4.2          1.4.2          1.4.2          Success
    Win     Win     1.4.1_02     1.4.2          1.4.2          Success
    Win     Win     1.4.2          1.4.0          1.4.2          Success
    Win     Win     1.4.2          1.4.1          1.4.2          Success
    Win     Win     1.4.2          1.4.2          1.4.2          Success
    Unix     Win     1.4.2          1.4.2          1.4.2          Success
    Unix     Win     1.4.2          1.4.2          1.4.1_02     Success
    Unix     Win     1.4.2          1.4.2          1.4.0          Success
    Unix     Unix     1.4.2          1.4.0          1.4.0          Success
    Unix     Unix     1.4.2          1.4.1          1.4.0          Success
    Unix     Unix     1.4.2          1.4.2          1.4.0          Failure
    Win     Unix     1.4.2          1.4.0          1.4.0          Success
    Win     Unix     1.4.2          1.4.1          1.4.0          Success
    Win     Unix     1.4.2          1.4.2          1.4.0          Failure

  • Satellite P305-S8909 - why the site doesn't have information about it?

    Hello
    Guys, I'd like to know if someone got this model: P305-S8909
    Does it really run warm as I saw in some reviews?
    Also, is a notebook worth getting?
    Is the keyboard good?
    Why can't I find this model anymore in some websites? Did it get discontinued?
    Also, this model has LED LCD?
    Thanks!

    Hi
    A friend of me has the Satellite P300 that is very similar to the Satellite P305. He is very satisfied with this notebook and dont have any problems with it. The notebook isnt getting more hot as other notebooks the keyboard with extra numpad is very useful.
    Normally you can find all informations about this notebook on the Toshiba US page:
    http://www.csd.toshiba.com
    But as the other users said I would wait for the P500. I have a little bit searched with Google and its a very interesting and nice notebook. ;)

  • Why the comparison doesn't work?!

    my code is:
    <text>
      <boundAttribute name="text">
       <if>
         <comparison  type="greaterThanOrEquals">
           <fixed javaType="int" text="10"/>
           <fixed javaType="int" text="8"/>
         </comparison> 
         <fixed javaType="string" >aaaa</fixed>
         <fixed javaType="string">bbbb</fixed>
       </if>
      </boundAttribute>
    </text>whenever the comparison type is "greaterThan" or "lessThan" ,the result always is bbbb.
    i use jdev10g.
    thanks.

    thanks for your answer.it does work well.
    however,i want to compare a value of pageProp and a value of bc4j:attrValue,like following:
    <text>
      <boundAttribute name = "text">
        <if>
           <comparison type="greaterThanOrEquals">
              <dataObject select="SetPayDate" source="${uix.pageProp}"/>
              <bc4j:attrValue name=DateDue"/>
           </comparison>
        <fixed javaType="string"> aaa </fixed>
        <fixed javaType="string"> bbb </fixed>
        </if>
       </boundAttribute>
    </text>
    i have ever seen that it worked well. The second day,it didn't work. :(.
    thanks.best regards.

Maybe you are looking for

  • Windows 8.1 disk 100% utiization

    Hi Team I am using HP envy m4  Windows 8.1 i7 8gigs ram. My disk usage is always 100% no matter what i do. Can you please let me know what might have caused the issue. I havent observed till my laptop start freezing and today it gave my screen saying

  • Crazy Headphone problem? Speaker no longer works in some cases

    Gang, Basically my phone work just fine. But when I get a call I have to put it on speaker phone to listen to anything. Also when I adjust the volume it always indicates Headphone. and Yes I do not have my headphones in. I looked at the cleaning thin

  • Adobe interactive form: Fields not fillable

    Hi, I followed this fantastic e-learning session on [Send, Receive, and Process Interactive Forms via Email in SAP Application Server - ABAP (Session 4A)|http://www.sdn.sap.com/irj/scn/elearn?rid=/library/uuid/5087262b-59ef-2910-abb1-957000b7c3d4]. I

  • IChat 5.0 - iChat connections got worse since upgrade to Snow Leopard.

    Hi. Me and my significant other chat on a dayli basis, so "Improved" video and audio in Snow Leopard (iChat 5.0) seemed like a golden "Must buy". Since I installed it, she has reported issues with my audio and video. She says it lags to the point whe

  • Is my Adobe CC for photographers license still valid if I change from Windows 32 bit to 64 bit?

    I've bought a license for Adobe CC for photographers (costs 10$ a month), and now going to upgrading my operating system from Windows 7 32 bit to 64 bit. I know that there is a 64 bit version for Photoshop, don't know about Bridge. So, is my license