Warning  "unchecked or unsafe operations" when use Vector

Can any one tell me why i get "unchecked or unsafe operations " warning.
What I want to do is return 2 vector from the first method but i figure out by making it as object array would make thing easier for me. Then i try to use it on the second method and it give me error. The program still run fine but I just want to know what happen and what the affect of keeping it?
   public static Object[] chessPosition()
        Vector <Component> blackLocation = new Vector <Component> ();
        Vector <Component> whiteLocation = new Vector <Component> ();
         for(int y = 0; y < 8; y++)
             for(int x = 0; x < 8; x++)
                 Component c = ChessBoard.board.findComponentAt(x*75, y*75);
                 if(c instanceof JLabel)
                     if(c.getName().startsWith("white"))
                         whiteLocation.add(c);
                     if(c.getName().startsWith("black"))
                         blackLocation.add(c);
        Object [] a = new Object[2];
        a[0] = blackLocation;
        a[1] = whiteLocation;
        return a;
    public static void blackPotential()
        Object[] a = chessPosition();
        Vector <Component> blacks = (Vector <Component>)a[0];
    }Thanks in advance

Lest I make a jackhole of myself:
        Object[] a = chessPosition();
        Vector<Component> blacks = (Vector<Component>) a[0]; You're casting objects to a vector of Components.
Try this on for size:
    public static Vector<Vector<Component>> chessPosition()
        Vector<Component> blackLocation = new Vector<Component>();
        Vector<Component> whiteLocation = new Vector<Component>();
        for (int y = 0; y < 8; y++)
            for (int x = 0; x < 8; x++)
                Component c = ChessBoard.board.findComponentAt(x * 75, y * 75);
                if (c instanceof JLabel)
                    if (c.getName().startsWith("white"))
                        whiteLocation.add(c);
                    if (c.getName().startsWith("black"))
                        blackLocation.add(c);
        Vector<Vector<Component>> v = new Vector<Vector<Component>>();
        v.add(blackLocation);
        v.add(whiteLocation);
        return v;
    public static void blackPotential()
        Vector<Vector<Component>> a = chessPosition();
        Vector<Component> blacks = (Vector<Component>) a.get(1);
    }Joe
XLint's still your friend
Message was edited by:
Joe_h

Similar Messages

  • Warning : PerformRecord.java use uncheck or unsafe operations

    /*When compile (with version 1.5.0_05) have a warnning message
    Note : PerformRecord.java use uncheck or unsafe operations
    Note : Recompile wiht -XLint : uncheck for details
    How can I solve this problem*/
    this is my code :
    import java.sql.*;
    import java.util.*;
    public class PerformRecord
         public static final String DEFAULT_DRIVER = "sun.jdbc.odbc.JdbcOdbcDriver";
    public static final String DEFAULT_URL = "Jdbc:Odbc:PersonalODBC";
    public static final String DEFAULT_USERNAME = "Personal";
    public static final String DEFAULT_PASSWORD = "moshan74";
         public Connection conn = null;
         public String querySQL;
         /*==Constructor class== */
         public PerformRecord()
              /*load JDBC driver*/
              try{
                   Class.forName(DEFAULT_DRIVER);
              }catch (ClassNotFoundException e){System.err.println(e.getMessage());}          
         /*===Method class*/
         /*set value for connection var*/
         public void getConnection()
              this.conn = setConnect();
         /*get QuerySQL*/
         public void setQuery(String sql)
              this.querySQL = sql;
         /*open connection */
         public Connection setConnect()
              try{
              conn = DriverManager.getConnection(DEFAULT_URL,DEFAULT_USERNAME,DEFAULT_PASSWORD);               
              }catch (SQLException e){System.err.print(e.getMessage());     }
              return conn;
         /*close connection*/
         public void closeConnect()
    try{
    conn.close();
    }catch (Exception e){ }
         /*execute query statement */
         public Object executeQuery()
              Object returnValue = null;
              try{
                   /*executing query and check result */
                   Statement stmt          = conn.createStatement();               
                   boolean hasResultSet = stmt.execute(querySQL);
                   if (hasResultSet)
                        /*get set of the record*/
                        ResultSet rs               = stmt.getResultSet();
                        /*get set of the column*/
                        ResultSetMetaData meta = rs.getMetaData();
                        /*amount column*/
                        int numColumns = meta.getColumnCount();
                        /*arrayLisst to add data*/     
                        List rows          = new ArrayList();
    while (rs.next())
    Map thisRow = new LinkedHashMap();// 1 element(1 row,i column)
    for (int i = 1; i <= numColumns; ++i)
    String columnName = meta.getColumnName(i);
    Object value = rs.getObject(columnName);
    thisRow.put(columnName, value);
    rows.add(thisRow);
    rs.close();
    stmt.close();
                   this.closeConnect();
    returnValue = rows;
    else
    int updateCount = stmt.getUpdateCount();
    returnValue = new Integer(updateCount);
              }catch (SQLException e){System.err.print(e.getMessage());     }
    return returnValue;
    ps>> I want to to use Generics to help it but I don't know how to do it in the right way . Can you you help me?
    Thanks
    Arunya

    regarding your Map/LinkedHashMap, since you keys are String and you values are Objects... you would define you Map using those two as you data type pair...
    ap<String,Object>thisRow = new LinkedHashMap<String,Object>();and similar for you List/ArrayList where you putting Maps into...
    List<Map<String,Object>> rows = new ArrayList<Map<String,Object>>();for more information on generics read...
    [url http://java.sun.com/docs/books/tutorial/java/javaOO/generics.html]Sun's The Java Tutorial : Generics
    - MaxxDmg...
    - ' He who never sleeps... '

  • Jdeveloper warning uses unchecked or unsafe operations

    Greetings:
    I am getting warnings on my oc4j console that look like :
    Note: C:\product\10.1.3\OracleAS_1\j2ee\home\application-deployments\pl\plBeans\generated\PlLoginPrefixesEJB_StatelessSessionBeanWrapper9.java uses unchecked or unsafe operations.
    Note: Recompile with -Xlint:unchecked for details.
    I get these when I use a JDeveloper created SessionEJB bean. Is there something i can do to "fix" this or should i just ignore it?
    Thanks
    troy

    Hi,
    I have the following code which I have got from a book but when I compile I get a warning .... uses unchecked or unsafe operations.
    class CompTypeComparator implements Comparator
      public int compare(Object o1, Object o2)
        int j1 = ((CompType)o1).j;
        int j2 = ((CompType)o2).j;
        return (j1 < j2 ? -1 : (j1 == j2 ? 0 : 1));
    public class ComparatorTest
      public static void main(String[] args)
        CompType[] a = new CompType[10];
        Arrays2.fill(a, CompType.generator());
        System.out.println("before sorting, a = " + Arrays.asList(a));
        Arrays.sort(a, new CompTypeComparator());
        System.out.println("after sorting, a = " + Arrays.asList(a));
    }I have met this error before in other code from the book and have been able to sort it by myself. This one I could not solve since I do not fully understand the syntax of the Arrays.sort() method. IE
    sort(T[] a, Comparator<? super T> c)Presumably this error is because the book used an older version of the compiler than the version I am using (V5.0 or is it V1.5).
    Could anyone explain the error, how I can solve it and what the sort method means particularly "? super T"?
    Regards FarmerJo

  • Owner.java uses unchecked or unsafe operations.

         * addVecOwners() Method
         * @param g the is the Owner object
         * The method is used to add the owner
    public void addVecOwners(Owner ow)
        getVecOwners().add(ow);
    or
         * addVecBoats() method
         * @param bt holds the Boat object
    public boolean addVecBoats(Boat bt)
         boolean result = false;
         if( getVecOwnerBoats().contains(bt) == true )
              result = false;
         else
              getVecOwnerBoats().add(bt);
              result = true;
         return result;
    }          Above are the two type of sample coding I typed. I get the following errors when I typed it.
    Owner.java uses unchecked or unsafe operations.
    Note: Recompile with -Xlint:unchecked for details.
    Please help me to get ridof the warning messages.

    If you decide to use generics, you'll have to modify your code
    everywhere you use the collections.
    Before:
    private Vector vecOwners = new Vector();
    private Vector vecOwnerBoats = new Vector();
    public Vector getVecOwners()
        return vecOwners;
    public Vector getVecOwnerBoats()
        return vecOwnerBoats;
    public void addVecOwners(Owner ow)
        getVecOwners().add(ow);    
    public boolean addVecBoats(Boat bt)
        boolean result = false;
        if (!getVecOwnerBoats().contains(bt))
            getVecOwnerBoats().add(bt);
            result = true;
        return result;
    }With generics:
    private Vector<Owner> vecOwners = new Vector<Owner>();
    private Vector<Boat> vecOwnerBoats = new Vector<Boat>();
    public Vector<Owner> getVecOwners()
        return vecOwners;
    public Vector<Boat> getVecOwnerBoats()
        return vecOwnerBoats;
    public void addVecOwners(Owner ow)
        getVecOwners().add(ow);    
    public boolean addVecBoats(Boat bt)
        boolean result = false;
        if (!getVecOwnerBoats().contains(bt))
            getVecOwnerBoats().add(bt);
            result = true;
        return result;
    }Regards

  • Use Unchecked or unsafe operations: recompile with -Xlint

    hi all..
    I'm trying to create a GUI to select the necessary port to open. I got this code from JAVA cookbook:
    I'm using windows XP and JDK 1.6..
    import java.io.*;
    import javax.comm.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import javax.swing.*;
    public class PortChooser extends JDialog implements ItemListener {
    HashMap map = new HashMap();
    String selectedPortName;
    CommPortIdentifier selectedPortIdentifier;
    JComboBox serialPortsChoice;
    JComboBox parallelPortsChoice;
    JComboBox other;
    SerialPort ttya;
    JLabel choice;
    protected final int PAD = 5;
    public void itemStateChanged(ItemEvent e) {
    selectedPortName = (String)((JComboBox)e.getSource()).getSelectedItem();
    selectedPortIdentifier = (CommPortIdentifier)map.get(selectedPortName);
    choice.setText(selectedPortName);
    public String getSelectedName() {
    return selectedPortName;
    public CommPortIdentifier getSelectedIdentifier() {
    return selectedPortIdentifier;
    public static void main(String[] ap) {
    PortChooser c = new PortChooser(null);
    c.setVisible(true);// blocking wait
    System.out.println("You chose " + c.getSelectedName() +" (known by " + c.getSelectedIdentifier() + ").");
    System.exit(0);
    public PortChooser(JFrame parent) {
    super(parent, "Port Chooser", true);
    makeGUI();
    populate();
    finishGUI();
    protected void makeGUI() {
    Container cp = getContentPane();
    JPanel centerPanel = new JPanel();
    cp.add(BorderLayout.CENTER, centerPanel);
    centerPanel.setLayout(new GridLayout(0,2, PAD, PAD));
    centerPanel.add(new JLabel("Serial Ports", JLabel.RIGHT));
    serialPortsChoice = new JComboBox();
    centerPanel.add(serialPortsChoice);
    serialPortsChoice.setEnabled(false);
    centerPanel.add(new JLabel("Parallel Ports", JLabel.RIGHT));
    parallelPortsChoice = new JComboBox();
    centerPanel.add(parallelPortsChoice);
    parallelPortsChoice.setEnabled(false);
    centerPanel.add(new JLabel("Unknown Ports", JLabel.RIGHT));
    other = new JComboBox();
    centerPanel.add(other);
    other.setEnabled(false);
    centerPanel.add(new JLabel("Your choice:", JLabel.RIGHT));
    centerPanel.add(choice = new JLabel());
    JButton okButton;
    cp.add(BorderLayout.SOUTH, okButton = new JButton("OK"));
    okButton.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent e) {
              PortChooser.this.dispose();
    /** Populate the ComboBoxes by asking the Java Communications API
    * what ports it has. Since the initial information comes from
    * a Properties file, it may not exactly reflect your hardware.
    protected void populate() {
    Enumeration pList = CommPortIdentifier.getPortIdentifiers();
    while (pList.hasMoreElements()) {
    CommPortIdentifier cpi = (CommPortIdentifier)pList.nextElement();
    // System.out.println("Port " + cpi.getName());
    map.put(cpi.getName(), cpi);
    if (cpi.getPortType() == CommPortIdentifier.PORT_SERIAL) {
    serialPortsChoice.setEnabled(true);
    serialPortsChoice.addItem(cpi.getName());
    else if (cpi.getPortType() == CommPortIdentifier.PORT_PARALLEL) {
    parallelPortsChoice.setEnabled(true);
    parallelPortsChoice.addItem(cpi.getName());
    else {
    other.setEnabled(true);
    other.addItem(cpi.getName());
    serialPortsChoice.setSelectedIndex(-1);
    parallelPortsChoice.setSelectedIndex(-1);
    protected void finishGUI() {
    serialPortsChoice.addItemListener(this);
    parallelPortsChoice.addItemListener(this);
    other.addItemListener(this);
    pack();
    //addWindowListener(new WindowCloser(this, true));
    }}When i compile this it says PortChooser.java uses unchecked or unsafe operation
    recompile with -Xlint(any one know what this is?)
    Is it the JDK version i'm using ? First i thought it's a security issue.As in windows is not letting me access the serial ports.
    I checked with device manager.My serial ports are open. Ichanged my BIOS settings as well..
    (I read inputs from parallel port.But i dont use the comm api for that)
    I have installed the rxtx gnu.io package as well..
    Tried import gnu.io.* instead of javax.comm.*; still the same compilatiion error!!!
    Thanks in advance
    goodnews:-(

    It is basically a warning (not an error) that the compiler gives you to let you know that you are using a raw type where Java now supports generic types.
    For example, in the code you use:
    HashMap where you can use HashMap<String,String> to let the compiler know that you intend inserting Strings for both the key and the value. The former is considered to be unsafe because the compiler cannot control what is inserted into the HashMap while in the latter case it can ensure that only Strings are used for both keys and values.
    The compiler is also letting you know that if you want to see the details of these "unsafe" operations you can use the -Xlint:unchecked option when compiling and the compiler will show you exactly which lines contain the code that is generating the warning. So to compile with this option you would use javac -Xlint:unchecked ClassToCompile.

  • MyJava.java uses unchecked or unsafe operations

    I get the following warning message when I use ant from within Eclipse:
    compile:
    [javac] Compiling 2 source files to C:\eclipse\workspace\StoreInfo\build
    [javac] Note: C:\eclipse\workspace\StoreInfo\src\StoreInfo.java uses unchecked or unsafe operations.
    [javac] Note: Recompile with -Xlint:unchecked for details.
    I tried running my ant script from a dos prompt and still get the same message. I know its just a warning, but has anyone got a clue as to what the message means? How can I modify my ant script to recompile withe the -Xlint option?
    Thanks
    vedshar

    Vedshar,
    these messages occur when you are using classes that support the new J2SE 1.5 feature - generics. You get them when you do not explicitly specify the type of the collection's content.
    For example:
    List l = new ArrayList();
    list.add("String");
    list.add(55);If you want to have a collection of a single data type you can get rid of the messages by:
    List<String> l = new ArrayList<String>();
    list.add("String");If you need to put multiple data types into once collection, you do:
    List<Object> l = new ArrayList<Object>();
    list.add("String");
    list.add(55);If you add the -Xlint:unchecked parameter to the compiler, you get the specific details about the problem.
    Vita Santrucek

  • ... uses unchecked or unsafe operations?

    Hi,
    I have the following code which I have got from a book but when I compile I get a warning .... uses unchecked or unsafe operations.
    class CompTypeComparator implements Comparator
    public int compare(Object o1, Object o2)
    int j1 = ((CompType)o1).j;
    int j2 = ((CompType)o2).j;
    return (j1 < j2 ? -1 : (j1 == j2 ? 0 : 1));
    public class ComparatorTest
    public static void main(String[] args)
    CompType[] a = new CompType[10];
    Arrays2.fill(a, CompType.generator());
    System.out.println("before sorting, a = " + Arrays.asList(a));
    Arrays.sort(a, new CompTypeComparator());
    System.out.println("after sorting, a = " + Arrays.asList(a));
    I have met this error before in other code from the book and have been able to sort it by myself. This one I could not solve since I do not fully understand the syntax of the Arrays.sort() method. IE
    sort(T[] a, Comparator<? super T> c)
    Presumably this error is because the book used an older version of the compiler than the version I am using (V5.0 or is it V1.5).
    Could anyone explain the error, how I can solve it and what the sort method means particularly "? super T"?
    Regards FarmerJo

    Hi,
    I have the following code which I have got from a book but when I compile I get a warning .... uses unchecked or unsafe operations.
    class CompTypeComparator implements Comparator
      public int compare(Object o1, Object o2)
        int j1 = ((CompType)o1).j;
        int j2 = ((CompType)o2).j;
        return (j1 < j2 ? -1 : (j1 == j2 ? 0 : 1));
    public class ComparatorTest
      public static void main(String[] args)
        CompType[] a = new CompType[10];
        Arrays2.fill(a, CompType.generator());
        System.out.println("before sorting, a = " + Arrays.asList(a));
        Arrays.sort(a, new CompTypeComparator());
        System.out.println("after sorting, a = " + Arrays.asList(a));
    }I have met this error before in other code from the book and have been able to sort it by myself. This one I could not solve since I do not fully understand the syntax of the Arrays.sort() method. IE
    sort(T[] a, Comparator<? super T> c)Presumably this error is because the book used an older version of the compiler than the version I am using (V5.0 or is it V1.5).
    Could anyone explain the error, how I can solve it and what the sort method means particularly "? super T"?
    Regards FarmerJo

  • Uses unchecked or unsafe operations with deserialization

    Ive read a lot of posts and they all seem to say it something wrong with my generics and / or casting of them and I can't figure out what's wrong?
    First I created a Map as follows:
    Map<String, Map<String, Integer>> map = new HashMap<String, Map<String, Integer>>();
    String a = "A";
    Map<String, Integer> nodesA = new HashMap<String, Integer>();
    nodesA.put("B", 6);
    nodesA.put("H", 10);
    String b = "B";
    Map<String, Integer> nodesB = new HashMap<String, Integer>();
    nodesB.put("A", 6);
    nodesB.put("H", 2);
    String c = "C";
    Map<String, Integer> nodesC = new HashMap<String, Integer>();
    nodesC.put("B", 9);
    nodesC.put("D", 2);
    nodesC.put("F", 7);
    nodesC.put("G", 6);
    nodesC.put("H", 5);
    String d = "D";
    Map<String, Integer> nodesD = new HashMap<String, Integer>();
    nodesD.put("C", 2);
    nodesD.put("F", 2);
    String e = "E";
    Map<String, Integer> nodesE = new HashMap<String, Integer>();
    nodesE.put("D", 4);
    nodesE.put("F", 1);
    String f = "F";
    Map<String, Integer> nodesF = new HashMap<String, Integer>();
    nodesF.put("C", 7);
    nodesF.put("D", 2);
    nodesF.put("E", 1);
    String g = "G";
    Map<String, Integer> nodesG = new HashMap<String, Integer>();
    nodesG.put("C", 6);
    nodesG.put("F", 8);
    nodesG.put("H", 3);
    String h = "H";
    Map<String, Integer> nodesH = new HashMap<String, Integer>();
    nodesH.put("A", 10);
    nodesH.put("C", 5);
    nodesH.put("G", 3);
    map.put(a, nodesA);
    map.put(b, nodesB);
    map.put(c, nodesC);
    map.put(d, nodesD);
    map.put(e, nodesE);
    map.put(f, nodesF);
    map.put(g, nodesG);
    map.put(h, nodesH);Then I serialized the map as follows:
    FileOutputStream fos = new FileOutputStream("data");
    ObjectOutputStream oos = new ObjectOutputStream(fos);
    oos.writeObject(map);
    oos.close();
    fos.close();Then, in a different program, I tried to create a new map, set it to null to make 100% sure it was empty, and load in the map that I had saved, but when I try to compile this, I constantly get that uses unchecked or unsafe operations. I've tried all sorts of casting and such, and I can't figure out what it wants?
    Map<String, Map<String, Integer>> map = new HashMap<String, Map<String, Integer>>();
    map = null;
    output.println(map); 
    FileInputStream fis = new FileInputStream("data");
    ObjectInputStream ois = new ObjectInputStream(fis);
    map = (Map<String, Map<String, Integer>>) ois.readObject();
    ois.close();
    output.println(map); 

    The code you posted is correct, just add a @SuppressWarning("unchecked:). readObject returns an Object so you must cast and casting to a generic type will always produce a warning as the generic type information is erased (not available) at run time.
    You can read the warning in this case as 'possible class cast exception', which the compiler doesn't generate and you know that it shouldn't happen.

  • X.java uses unchecked or unsafe operations - Confused.

    Coming back to java after a few years of strict C/C++ development, and wanted to start out with a few refresher apps - However, there's one issue that's been bothering me and it's the "uses unchecked or unsafe operations". Now, I'm aware that this is outputted when generics are used without fully qualifying the underlying types; However, like in the example below, I just cannot figure out where I need to include additional type definitions in order to rid myself of this error:
    import java.util.HashMap;
    public class Widget implements Cloneable {
        private HashMap<String, Object> myMap;
        public Widget( ) {
            myMap = new HashMap<String, Object>();
        protected Widget clone() {
            try {
                Widget cloneObj = (Widget) super.clone();
                cloneObj.myMap = (HashMap<String, Object>) myMap.clone();
                return cloneObj;
            } catch(CloneNotSupportedException ex) {
                //Should not occur since we implemented clone(...)
                return null;
    }javac complains that the line of code which clones 'myMap' is unsafe, but how?
    Any help?

    } catch(CloneNotSupportedException ex) {
    //Should not occur since we implemented clone(...)
    return null;
    }Just because you implement Cloneable doesn't necessarily make an object cloneable. In this case you're going to be ok, but try cloning a Thread or a Component and you will get the CloneNotSupportedException

  • "unchecked or unsafe operation" Warnings

    i downloaded some source example code to run on my machine , but the code is based on java 1.4, my machine is java 5.0, and when i compile the code, the Note on "unchecked or unsafe operation" Warnings comes out. i've try to add the type of arrayList and hashMaps(the main data structure the code used)as the author said in his book, but the notes warning still come out...help me please...

    i downloaded some source example code to run on my
    machine , but the code is based on java 1.4, my
    machine is java 5.0, and when i compile the code, the
    Note on "unchecked or unsafe operation" Warnings
    comes out. i've try to add the type of arrayList and
    hashMaps(the main data structure the code used)as the
    author said in his book, but the notes warning still
    come out...help me please...don't panic! they are exactly what they say they are, warnings. no harm will come to you!

  • Unchecked or unsafe operations in db connection pooling

    In db connection poolong ,
    connections are kept in hash table.Iam getting error as unchecked or unsafe operations.
    can you rectify this
    regards
    preethi

    malcolmmc wrote:
    You don't necessarilly have to install retro compilers - you can set the source and target levels on the compiler command line e.g.
    javac -source 1.3 -target 1.3 ....That does not however prevent you from using methods (and I think classes) that don't exist in 1.3, only language features.
    It's especially nasty when dealing with new overloaded methods, where it will allow you to use new overloaded versions that don't exist in the old language version when compiling, and will allow them to be used when running against a 1.5 JVM, but when run against a 1.3 JVM you get exceptions because the method doesn't exist there.
    So be extremely careful using those flags, and test everything thoroughly against a 1.3 JVM (which kinda defeats the purpose of the flags, as it means you need one installed anyway so why not use that to compile in the first place?).

  • Unchecked or Unsafe operation -- recompile

    Hi,
    How can I set compiler options in Jdeveloper?
    I am getting a
    Note: C:\JDeveloper10131\j2ee\home\application-deployments\AbcEJBTest\AbcEJB\ejb_webs
    ervice1\runtime\ControllerResponseElement_LiteralSerializer.java uses unchecked or unsafe operations
    Note: Recompile with -Xlint:unchecked for details.
    I am looking to recompile with the "-Xlint:unchecked" option.
    Thanks.

    See Generics : compiler option : unchecked conversion warnings

  • Error - Unchecked or unsafe operations

    import java.io.*;
    import java.util.*;
    public class Dictionary
         // data members
          Hashtable Dictionary = new Hashtable();
          // constructor
          public Dictionary()
              for(int i=0; i<256; i++)
              Dictionary.put(new Integer(i), new Integer(i));
       Gets the following error
    Note: Dictionary.java uses unchecked or unsafe operations.
    Note: Recompile with -Xlint:unchecked for details.
    Any ideas ?

    Ah, I'm getting soft: do this:
    import java.util.*;
    public class Dictionary  {
        Hashtable<Integer, Integer> Dictionary = new Hashtable<Integer, Integer>();
        public Dictionary() {
            for(int i=0; i < 256; i++)
              Dictionary.put(new Integer(i), new Integer(i));
    }Tutorial: http://java.sun.com/docs/books/tutorial/extra/generics/index.html

  • Unchecked or  unsafe operations

    I am trying to compile code and I am receiving the error message unchecked or unsafe operations. I tried compiling it with the -Xlint:unchecked and it pointed towards a portion on the code I placed below. The code is too long to put the whole thing in here.
    private Vector getNextRow( ResultSet rs,
    ResultSetMetaData rsmd ) throws SQLException
    Vector currentRow = new Vector();
    for ( int i = 1; i <= rsmd.getColumnCount(); ++i )
    switch( rsmd.getColumnType( i ) ) {
    case Types.VARCHAR:
    case Types.LONGVARCHAR:
    currentRow.addElement( rs.getString( i ) );
    break;
    case Types.INTEGER:
    currentRow.addElement( new Long( rs.getLong( i ) ) );
    break;
    case Types.REAL:
    currentRow.addElement( new Float( rs.getDouble( i ) ) );
    break;
    case Types.DATE:
    currentRow.addElement( rs.getDate( i ) );
    break;
    default:
    System.out.println( "Type was: " +
    rsmd.getColumnTypeName( i ) );
    return currentRow;

    If Vector<String> currentRow = new Vector<String>(); isn't correct because there's different types you must find superclass of classes that you add, in this case, Object.
    Vector<Object> currentRow = new Vector<Object>();

  • How to get rid of "unchecked or unsafe operation" in J2SE 5.0?

    There is always such inofmration after I compile the code. How can I check if the code contains unchecked or unsafe operation"?

    There is always such inofmration after I compile the
    code. How can I check if the code contains unchecked
    or unsafe operation"?javac -source 1.4 xyz.java

Maybe you are looking for

  • How can I edit text in a tagged PDF?

    I have created an accessible test form in Acrobat Pro X.  Now that it has all been tagged and reading order touched up, the client wants to change the text.  Is there any way to edit text at this point or do I have to create an entirely new tagged ac

  • Printing of continuous similar pages in a script

    hi experts,         i have customized a script, the script contains only one page data. but i want to print the same script with small header content change for 5 times in one execution.. thanks & regards deepika

  • Problem in displaying Flash works (only in IE)

    Hi, we have problem in displaying the flash animations, as it shows a box like surrounding, after when we double click it, it gets activated. We face this problem only in IE and not in any other browsers. We want to know the technical reason for this

  • LG - 1000W 5.1-Ch. Home Theater System with Upconvert DVD/CD Player

    I have a question about the LG - 1000W 5.1-Ch. Home Theater System with Upconvert DVD/CD Player. Model: LHT854 | SKU: 8713859. I plan on purchasing this here soon. i was wondering how long the wires are to the satellite speakers.the front 2 and cente

  • Stopping Data Reception/Synchronization at the Phone

    I have a user that will be traveling out of the country and does not want email redirection being stopped at our BES server - he wants to be able to use the phone but not receive emails unless he turns a setting on the phone on (and conversely wants