Auto Boxing not working in Java 6?

Hi All,
I am studying and practicing to become Java Certified and I am just using an example from the Java Certification Guide Chapter 11 Swing Components from Sybex for Java 5.
I am using Eclipse and the latest Java 6 SDK in WIndows XP.
The code below runs fine in Solaris 10 using Java 1.5.0_14-b03:
import java.util.*;
import javax.swing.*;
import javax.swing.table.*;
public class StringLengthTableModel extends AbstractTableModel {
     private String[] strings;
     public StringLengthTableModel(String[] strings) {
          this.strings = strings;
     public int getRowCount() {
          return strings.length;
     public int getColumnCount() {
          return 2;
     public Object getValueAt(int row, int col) {
          if (col == 0) {
               return strings[row];
          } else {
               return strings[row].length();
     public String getColumnName(int col) {
          return (col == 0) ? "String" : "Length";
     public static void main(String[] args) {
          JFrame frame = new JFrame();
          String[] strings = { "January", "February", "March", "April", "May",
                    "June", "July", "August", "September", "October", "November",
                    "December" };
          StringLengthTableModel model = new StringLengthTableModel(strings);
          JTable table = new JTable(model);
          frame.getContentPane().add(table);
          frame.setSize(500, 250);
          frame.setVisible(true);
However in Windows XP and using the latest Eclipse IDE and the Latest Java 6 SDK I get:
Exception in thread "AWT-EventQueue-0" java.lang.Error: Unresolved compilation problem:
     Type mismatch: cannot convert from int to Object
The questionable method line is
               return strings[row].length();
in the method
     public Object getValueAt(int row, int col) {
          if (col == 0) {
               return strings[row];
          } else {
               return strings[row].length();
Any ideas????
You would think and hope the latest release of Java like Java 6 would be backward compatible with the auto boxing and auto un boxing features that were introduced in Java 5.
Any comments, thoughts, ideas would be appreciated.
Thanks,
Carlos A. Morillo
[email protected]

CarlosMorillo wrote:
Exception in thread "AWT-EventQueue-0" java.lang.Error: Unresolved compilation problem:
     Type mismatch: cannot convert from int to ObjectGo to that line in Eclipse and look for the red squiggly line. Click on the I symbol next to it. At a guess the project is set up to work in 1.4 mode.
Also learn to love the "Problems" panel. This should not have been a runtime error.
Any ideas????Your project is in 1.4 mode. Right click on the project in the "Project Explore" window. Select properties, select "Java Compiler", check the "Enable project specific settings" and make sure the little drop downs all say "6.0".

Similar Messages

  • Generics and Auto-boxing not working together

    Why does the following code produce a compile error:
    "Type mismatch: cannot convert from char to Character."
    public class X<Character> {
         private Character c;
         private Integer i;
         public X() {
              c = 'a';
              i = 12;
    }Note that if I change the class declaration to class X<Integer>, I'll get the error about converting from int to Integer, but the char error will disappear.

    I believe that the <Character> type parameter is hiding the java.lang.Character class. Your code is equivalent to this:
    public class X<T> {
         private T c;
         private Integer i;
         public X() {
              c = 'a';
              i = 12;
    }So what you really want is something like
    public class X<T> {
         private Character c;
         private Integer i;
         public X() {
              c = 'a';
              i = 12;
    }or maybe this, depending on what you're really trying to do
    public class X<T extends Character> {
         private T c;
         private Integer i;
         public X() {
              c = 'a';
              i = 12;
    }Of course, since Character is final, that doesn't really make sense either.
    Perhaps you could explain a bit more about what you're actually trying to accomplish.
    Edited by: jverd on Feb 26, 2010 11:24 AM
    Edited by: jverd on Feb 26, 2010 11:25 AM

  • Captivate 4 AS2 Text Entry Box not working with Flash Player 11

    I am having issues with text entry boxes not working at all in flash 11. I am using Captivate 4 and exporting an AS2 swf. When you get to the slide you can type but you cannot see anything nor does the button or keystroke to move on. Also there is no cursor. Any ideas?

    You said it is not working with Flash 11, so does that mean you tested with previous version and that worked?
    While publishing choose Flash player as 9 and publish that, verify if that plays in a compatible web browser.
    AS 2 is a legacy scripting, it has been said not too be supported with even Flash Player 10 --
    http://help.adobe.com/en_US/AS2LCR/Flash_10.0/help.html?content=Part2_AS2_LangRef_1.html
    I believe if you switch back to version 9 while publish your project, it should work.
    Thanks,
    Anjaneai

  • Applets not working with Java 1.7.0_51 in MII 14.0 SP4 Patch 5

    Hi,
    I'm currently evaluating the migration of our MII 12.0 developments to MII 14.
    But I'm running in several issues just trying to use simple things like a SQL query template with an iGrid Display template in test mode.
    Used versions are: MII 14.0 SP4 Patch 5 and on client side the latest Mozilla Firefox with Java 1.7.0_51
    At first I always get a java security warning when the applet is being loaded about unsigned applications.
    At second the applet itself is not running. It always shows "No data available" and the java console shows the following errors (iResult is the id of the applet):
    iResult [ERROR] - Couldn't set query template: No Query Defined
    iResult [ERROR] - Couldn't set display template: null
    iResult [ERROR] - Couldn't set display template: null
    Is this perhaps a general problem, that the MII applets are not working with Java 1.7.x versions?
    If I call the same MII page from a client with Java 1.6.x it is working without errors.
    Do you have some suggestions for me?
    Regards Timo

    please clear your JAVA Cache. that should solve the JRE issue. thanks

  • BAPI not working in Java Webdynpro

    Hi,
    My BAPI from SAP is working in Netweaver perfectly, but when I call the same with the equal parameters in Java webdynpro, no results.
    I'm using following function: 'CVAPI_DOC_VIEW'.
    Any idea why the BAPI is not working in Java Webdynpro?
    Regards,
    Tim

    Hi Tim,
    AFAIK 'CVAPI_DOC_VIEW'  will work only in standard SAP Dynpro. Inside Webdynpro it is forbidden to save files in the background and using GUI class with execute, so you cannot use that Standard FM.
    Check this thread .
    Thanks
    Katrice

  • Auto brightness not working in ios6

    I updated my iPad (3rd gen) to ios6, but when the update is complete i found that the auto brightness not working, when i use the ipad on dark room the brightness not changing, when i use ios5.1 it changing.. Any solution and actually the problem is on ios or in the hardware? Looking for help asap...

    Well my device is different and since it is a iPhone 5, it is not being updated to iOS 6 but the issue is exactly the same. From my mind this could be up to software but also could be from an hardware issue. The thing is that even if it worked before iOS 6 for you the new software could have revealed hardware conflicts since the software interacts different with the hardware for some features. This would be the worst case scenario because I know that normally iPhone 4 devices if not the 8GB model will be out of warranty. For me this is just a small issue since my warranty is still one year :(
    I have contacted apple care for this issue and have get the info that it will be escalated to the engineering team, for further investigation. As I know there was also an issue with some proximity sensors at the beginning if the iPhone 4 models and I think there was an software fix for a lot of them. Hope for the best!!!
    I have also done a lot of Troubleshooting, reseted settings, content and settings, restored in dfu and recovery mode, restored with new .ipsw (iPhone OS), restored on different pc (so even this step gas downloaded a totally new .ipsw file), first on a Mac!
    Next step wis that I will let the battery drain low entirely, a Troubleshooting idea of an friend. This might empower the entire hardware for a restart. I am not really believing in this step but I will give it a try :)

  • AUto attendant not working

    Auto attendant not working .....
    If i assign AA script Transfer_v02.aef then i hear an just 1-2 seconds the script after that again it is just ringing ...
    Is there Option to set
    Please press the extension which you want to Call ...
    Eg: if i press 222 that time it should ring the 222 extension
    Please help this is the first time i am working on this stuff
    If i chnage the scrpt file then i can hear auto attendant not initiazlised..  please find the attched screen shot and back file for more details.
    Best Regards
    Shabeel

    Hi KMS, check the codec used between that GW using the FXO and the CTI RP.
    Check also the Calling Seach Space
    GW should be able to reach CTI Route Point and CTI ports partition.
    If you try other extension it works fine?

  • Auto keyframe and auto transition not working

    auto keyframe and auto transition not working and I have a creative cloud, in addition the auto keyframe works in the getting startel lessons....

    In order to use these you need to have the autokey frame and transition selected
    OFF   ON
    and have the first key checked then move the playhead to the new position and it should add the transition.
    Did you try this and it is not working?.

  • Auto dial not working

    Auto dial not working
    I'm using an iPad 4, with WiFi and Cellular and iOS 8.1.3
    In the past if I was searching for a hotel and found one I only had to tap on the phone number and it would dial using either Skype or MagicJack. It worked using Wi-Fi or my data plan. It was an absolutely valuable function especially when traveling.
    Now, when I click on a phone number, it says that it's going to exit the program (like Safari) and start a new program. When I click, Ok, nothing happens.
    I must have inadvertently changed some setting.
    Skype works, MagicJack works, but I must dial the number manually.
    I have tried turning "Handoff" off and on then rebooting, turning FaceTime off and on and rebooting (and every combination of those two programs and actions).
    To say the least, I am frustrated because it must be something obvious. (to everyone else!)
    Any ideas as to how to how I can get it to dial automatically again?
    Thanks for any assistance.

    IPAD user guide for IOS 8 is available on line at apple -
    you can download it in IBOOK or PDF format to refer to when you can't get connected to see it on-line
    http://support.apple.com/manuals
    Handoff is only for using with multiple devices - Iphone/Ipad/ipod
    This is the bit in Handoff on Phone calls
    Phone calls
    If your iPhone (with iOS 8) is nearby, you can make and receive phone calls on your other iOS devices and Mac computers. All devices must be on the same Wi-Fi network, and signed into FaceTime and iCloud using the same Apple ID.
    Make a phone call on iPad. Tap a phone number in Contacts, Calendar, or Safari. You can also tap a recent contact in the multitasking screen.
    Disable iPhone Cellular Calls. On your iPhone, go to Settings > FaceTime, then turn off iPhone Cellular Calls.
    You may have to use Face Time to make calls from the IPAD -- there are page or 2 on that --

  • Auto brightness not working on iPhone 5?

    On the iPhone 5 - In the settings, when flicking the auto brightness on/off the screen shows no change in brightness - whether in a completely dark room or with the lights on etc. My iPhone 4 has been updated to IOS6 and seems to be working normally (brightness auto adjusts in all situations).
    Anyone else have this problem of the auto brightness not working?

    There is nothing wrong with the auto brightness.
    When you have auto brightness enabled the slider works as the minimum brightness setting with auto brightness.
    If you have the slider too high the brightness cant reduce because youre not letting it.
    Set your brightness at about 25% and you'll see what I mean.

  • Office 2013 Auto Archiving not working

    Dear Sir / Madam,
    We are using MS OFFICE 2013 with Windows 8.
    Problem we face is Auto Archiving not working at all. We have defined all the parameters, still it is not working. We are using Exchange Server and all the emails are Archived to local PST files after a defined time period.
    We have defined all the steps required to do Auto Archiving.
    Your help is required in this since we have tried all the options.
    Paloli Manoj

    Hi,
    What's the size or your archive.pst file? Please first make sure it's not getting close to 50 GB limit.
    If the size far below 50 GB, please try to use the Inbox Repair tool to scan and repair the archive.pst file. If the file is corrupt, the autoarchive will not happen.
    http://office.microsoft.com/en-in/outlook-help/repair-outlook-data-files-pst-and-ost-HA102749454.aspx?CTT=1
    For more troubleshooting steps, please refer to this:
    http://www.howto-outlook.com/faq/archivenotworking.htm
    Regards,
    Steve Fan
    TechNet Community Support

  • Windows Server 2008 R2 DNS Entry Auto remove not working

    Dear All,
    I have configured DNS Ageing for 30 days removal of unwanted host entry.but it will not work.
    Active directory DNS having all unwanted host in forward lookup zone and as well as reverse lookup zone.
    how to solve this ?
    pls help
    Sunil
    SUNIL PATEL SYSTEM ADMINISTRATOR

    Hi,
    This is a rather common problem when configuring Scavenging and Aging of stale DNS entries.  This has to be set in two spots, not just one as so many admins have difficulties with.  It isn't very obvious. 
    Aging and Scavenging must be set on both the DNS Server and on the Zone
    that you want to clean.  In addition, DNS needs to be Active Directory integrated and resource records need to be dynamically registered.  Static entries are ignorned.
    First step: 
    To set aging and scavenging properties for the DNS Zones using the Windows interface           
    Open DNS Manager.
    In the console tree, right-click the applicable DNS server, and then click
    Set Aging/Scavenging for all zones.
    Select the Scavenge stale resource records check box.
    Modify other aging and scavenging properties as needed.
    Second Step:
    To set aging and scavenging properties for the DNS Server using the Windows interface           
    Open DNS Manager.
    In the console tree, right-click the applicable DNS server, and then click
    Properties.
    Select the Advanced tab,and then enable Enable automatic scavenging of stale records
    check box. Once done, specify the Scavenging period (That is recurring
    interval for Scavenging on a DNS server)  and click on OK
    That will do it.  Your DNS entries will then start auto scavenging based on the times you have determined. Word of caution - do not set your aging too aggressively - I have seen where an admin had set aging down to 1 day and when it finally kicked
    off, nearly brought the company to a halt. 

  • Font Auto-Activation Not Working After First Use

    Anyone else seeing this problem, or have a fix? Font auto-activation stops working after the first use. Here's what happens: Open a file that contains a font that is installed, but is disabled in Font Book. The dialog box "Application wants to use the font XXX". Click on Allow. The font will be available, as you expect. Now quit the application. Open the file again - you won't get the dialog box asking permission to use the font, and the font is not available. This happens in Pages 3.0.1 and TextEdit 1.5. It happens for each individual font - in other words, continuing my description, if you now open a second file that has another font that is disabled in Font Book, you'll be asked permission to use it. But once you've allowed a particular font to be used, you won't be asked permission again.

    Make a backup.  Restore the device as new.  Test the issue again.  If it persists, your device needs service.  If the issue disappears, restore your backup.  If it then reappears, then there is some form of corrupt data on the device from the backup.  You'll have to restore that data one portion at a time to determine what is causing it, or set up the device as new.

  • Yoga 2 Pro tent mode and auto-rotate not working

    I have had a Yoga 2 Pro since June. Recently the Tent mode and auto-rotate features do not work.
    When I put the Yoga 2 Pro into Tent mode the keyboard and touch pad are still active underneth. However, they shutoff when in tablet mode. Lenovo Transition starts automatically and is running.
    Auto-rotate does not work at all now. The screen is un-locked.

    Dear NX3
    Welcome to Lenovo forums
    Please try to uninstal the Lenovo transition program and download the version in the below link and instal it
    http://support.lenovo.com/us/en/downloads/ds038767
    Thanks
    Did someone help you today? Press the star on the left to thank them with a Kudo!
    If you find a post helpful and it answers your question, please mark it as an "Accepted Solution"! This will help the rest of the Community with similar issues identify the verified solution and benefit from it.
    Follow @LenovoForums on Twitter!

  • CISCO Box not working with Infrared Remove Control Repeater

    There was an Infrared Remote Control Repeater set-up in my newly purchased house.  It works for my LG DVD player, but does not work with my CISCO CHS435HDB box.  Are there any work around for this?  Should I change to a different box?

    If you are using a repeater, make sure the piece that is relaying the IR signal is pointing directly the font of the Cisco box and nothing is plugged into the IR input port in the back of the box.
    Anthony_VZ
    **If someones post has helped you, please acknowledge their assistance by clicking the red thumbs up button to give them Kudos. If you are the original poster and any response gave you your answer, please mark the post that had the answer as the solution**
    Notice: Content posted by Verizon employees is meant to be informational and does not supersede or change the Verizon Forums User Guidelines or Terms or Service, or your Customer Agreement Terms and Conditions or plan

Maybe you are looking for