Hashtable keys() deprecated

Hi,
i run my old 1.4.2 java with java 6 but i get a warning if i build my app:
warning: [dep-ann] deprecated item is not annotated with @Deprecated
Code:
public Enumeration<String> getContentKeys() {
          return (htData.keys());
htData is a hashtable, but i dont know what is deprecated??
What is the Problem here?
I have search the forum, but didn't found the solution, if there is a thrad, then plz link
Greets ph0e

You have a method with the "@deprecated" JavaDoc tag but without the @Deprecated annotation. The annotation was introduced in Java 5 and has pretty much the same purpose as the JavaDoc tag, but can be read at runtime.
You should add the @Deprecated annotation to every place where you use the @deprecated JavaDoc tag, but if you don't then you won't have any major problems.

Similar Messages

  • Ignoring case in Hashtable key names

    Is there any way to check a Hashtable for a key value (which is a string) but to ignore the case of the letters in the string?
    if(hashtable.contains(keyValue)){ .... }
    returns false if the string keyValue has different capitalization from the key in the hashtable.
    Thanks
    J A

    No, if you want to do it by subclassing Hashtable (incidentally, why Hashtable rather than HashMap?) then you want to override the put, get, contains, and remove methods to call String.lowerCase() on the key. Sylvia's suggestion was to insert a wrapper around String into the map rather than to subclass the map.

  • Rename hashtable keys

    I need to rename some keys in an Hashtable, and i'm wondering if there are "better" ways than creating a new Hashtable and copying the values into it with different key names.

    About using HashMap instead of Hashtable i'm not sure
    i can do so, because i'm just modifying a part of a
    huge web app and i'd need to make sure the change
    doesn't affect other parts. Don't mess with it if you don't have to. I assumed (incorrectly) that this was a new program.
    By the way what's the
    advantage of HashMap over Hashtable ?HashMap isn't synchronized, and has some additional performance benefits over Hashtable. That doesn't mean that Hashtable is used when you need to synchronize the Map. The Collections class provides a method for that. The main reason is that Hashtable was replaced with HashMap. A new hashtable implementation was not created for no reason. There were problems with the original design. HashMap is a living class and will be updated and improved upon as needed. We can't say the same for Hashtable. The main reason Hashtable is still around is that it is used in too much code in the JDK and elsewhere. A lot of developers still use it and I think that's a huge mistake.

  • Use of primitive datatypes as hashtable key finally OK?

    Are we finally at the point where we can use primitive values as keys in a hashtable? I know that this wouldn't work in the past, and I haven't needed to use a hashtable for years, so I haven't really cared.
    Yesterday I tried it in a program compiled for JVM 1.5, using ints for the keys, and it runs fine. Admittedly, I do get several "unchecked operation" warnings during compilation.

    Yesterday I tried it in a program compiled for JVM
    1.5, using ints for the keys, and it runs fine.
    Admittedly, I do get several "unchecked operation"
    warnings during compilation.It autoboxed the ints as Integers for you. Under the covers it is still using Integer objects.

  • Need to test for a Hashtable key in JSTL

    What I am trying to accomplish is to test a Hashtable for a specific key and if it is there run some HTML.
    This is my code but it obviously wrong since JSTL yells at me when I try to execute it.
    <c:set var="hash" scope="page" value="${UpdateStatusData}"/>
         <c:if test="${hash.containsKey('success')}">
              success
         </c:if>UpdateStatusData is a Hashtable. How can I modify this "code" in oder to test for a key?
    Thanks

    EL != java
    Luckily EL handles Maps quite well:
    <c:set var="hash" scope="page" value="${UpdateStatusData}"/>
    // one way
    <c:if test="${not empty hash.success}">
         success
    </c:if>
    // an alternative syntax
    <c:if test="${not empty hash['success']}">
         success
    </c:if>Cheers,
    evnafets

  • HashTable keys() strange behaviour in JDK 1.3

    Hi,
    Has the behaviour of the keys()-method in HashTable changed from JDK 1.2.2 to JDK 1.3? I get this strange results:
    I have a hashtable, and asks it for an enumration of the keys using the keys()-method. In JDK 1.2.2 (in the debugger of the Visual Age IDE) this works fine and I'm able to go through the enumeration and use all the keys.
    However, when I run the same code in JDK 1.3, the enumeration returned does not contain all keys, and some keys are duplicated in the enumeration.
    I was able to circumvent this by getting a key Set (with the keySet()-method), ask the set for its Iterator, go through the Iterator and putting the keys in a Vector and finally asking the Vector for its elements as an enumeration.
    This way I got all the keys once, and it worked both in JDK 1.2.2 and in JDK 1.3.
    I think only one thread is accessing the HashTable at the same time.
    Have anyone experienced a similiar behaviour and/or knows the cause of it?
    Regards,
    Magnus Erkstam

    I've run into several cases where what passes for Java 1.2 in Visual Age for Java does not behave in accordance with the JLS, or does not behave the same as other versions of Java 1.2. In my case the differences came up with regard to method invocation. VA4J resolved what should've been ambiguous method invocations entirely based on the signature of the method.
    http://forum.java.sun.com/thread.jsp?forum=31&thread=322726
    That thread talks about those problems, but also mentions an article I found which details diffences some researchers found between VA4J and several other compilers.
    http://www.cis.nctu.edu.tw/~wuuyang/papers/CTHPC2002ambiguities.pdf
    Wouldn't surprise me to hear there are ambiguities in the VA4J version of .equals() either.

  • Get a Hashtable key given a value

    hi,
    can anyone tell me how I get a the key of Hashtable value given the value. I cant see anything in the api, and having been trying to figure this out for hours.
    Hashtable numbers = new Hashtable();
    numbers.put("one", new Integer(1));
    numbers.put("two", new Integer(2));
    numbers.put("three", new Integer(3));
    if say I had value Integer 2, how can I find the key of this if I didn't know the key.

    I prefer HashMaps. You have to look for it yourself.import java.util.*;
    public class Test3 {
      public static void main(String[] args) {
        String[] data = {"Zero","One","Two","Three","Four","Five","Six"};
        HashMap hm = new HashMap();
        for (int i=0; i<data.length; i++) hm.put(data, new Integer(i));
    Random rand = new Random();
    Set keys = hm.keySet();
    for (int i=0; i<10; i++) {
    Integer value = new Integer(rand.nextInt(data.length));
    System.out.println("Looking for "+value);
    for (Iterator iter=keys.iterator(); iter.hasNext();) {
    Object key = iter.next();
    if (value.equals(hm.get(key))) {
    System.out.println(" Found key '"+key+"' with value '"+value+"'");
    }You might think about a reverse hashmap or else letting us know what you are trying to do.

  • Hashtable keys and enumeration

    Enumeration enumObj=hashAllDetails.keys();
    String strarray[]=null;
    while(enumObj.hasMoreElements())
    strarray[]=(String)enumObj.nextElement();
    for(int i=0;i<strarray.length();i++)
    System.out.println(strarray);
    hashAllDetails is hashtable.
    how can i get the keys of the hashtable into a string array. actually i have to compare each of the keys in the hashtable and check for single occurence.
    plz help me out.

    hi
    thanks a lot.
    i have to this too.
    Enumeration objEnumKeys = hashAllDetails.keys();
    while(objEnumKeys.hasMoreElements())
    String strHashKey = (String)objEnumKeys.nextElement();
    UserDetails objUserDetails = (UserDetails) hashAllDetails.get(strHashKey);
    System.out.println(objUserDetails.userid);
    i have the following code.
    in the hashtable hashAllDetails i have done this earlier
    hashAllDetails.put(keys,objUserDetails)
    UserDetails is a class with various fields. like userid, balance etc.
    now i need to get these userid values from the hashtable with are stored in the objects of UserDetails and need to compare values of userid field for single occurence.
    hope u can help me out. thanks..

  • Hashtable keys( ) question

    Hello guys,
    I have a question regarding hashtables.
    Here is a method which returns a vector that contains some items:
    public Vector getVectorItems()
            Vector oVector  = new Vector();
            Enumeration oEnum = coQueue.keys();
            while (oEnum.hasMoreElements())
                    oVector.add((String)oEnum.nextElement());
            return oVector;
    }My Question:
    There are times that when oVector is returned, it is empty.
    Up to now, I'm still wondering why is the vector was empty.
    Thank you very much for your help.

    You can use an Iterator instead ...
    public Vector getVectorItems() {
    Vector oVector = new Vector();
    Iterator iter = ((Set)coQueue.keySet()).iterator();
    while (iter.hasNext()) {
    oVector.add((String)iter.next());
    return oVector;
    Also, assuming coQueue is a HashMap, use the function KeySet() instead of keys().
    try it ....

  • Match not functioning for hashtable keys

    Updated
    Hello,
    I'm seeing unexpected behavior and am hoping for a little help.
    My PS ver is:
    Major  Minor  Build  Revision
    3      8      0      129 
    Here is a snip that illustrates the issue (reproducible)
    $aRecords = $null; $aRecords = @{}
    $aRecords.add('tblARecords_1_txtHost','1.1.1.2')
    $aRecords.add('tblARecords_0_txtHost','1.1.1.1')
    $aRecords.add('tblARecords_1_txtPointsto','1.1.1.2')
    $aRecords.add('tblARecords_0_txtPointsto','1.1.1.1')
    $gdRecords = $null; $gdRecords = @{}
    $gdRecords['typeA'] = $aRecords
    $records = $null;$records = @()
    $records = 'tblARecords_0'
    foreach($g in $gdRecords.Keys) {
    foreach($d in $gdRecords[$g]) {
    if($d.Keys -match $records) {
    write $d
    $records = tblARecords_0
    But the results i get back are 
    tblARecords_1_txtHost
    tblARecords_0_txtHost
    tblARecords_1_txtPointsto
    tblARecords_0_txtPointsto
    Even if i substitute the the variablw $wr with the string itself ('tblARecords_0'). It still produces the same same results
    Any help would be appreciated

    I understand that he is devoting his own time and effort, and that he is not a MSFT employee. For that i am appreciative. My issue is that an approved moderator should be a bit more thoughtful with his language. Normally i wouldn't care but am having one
    of those days. Problem is someone may be put off from that approach and may not come back. Perhaps also move on to something else as a result.
    I also agree with his request, I probably should have made a reproducible script prior to posting and am updating my question.
    Sorry but I disagree.  I know you believe your post is useful and explains everything.  It doesn't.  None of us can decode your variables or comments because we do not have your environment or the full script.
    Bill was trying to point put that you need to put in more effort to ensure those who are trying to help you do not have to play guessing games.
    Items 7 and 8 are exactly to the point.  Addres those issues and you will likley get a quick and correct answer.
    Here are items 7 and 8:
    7. Let someone else devise a repro case. When the button click handler isn't called in your sample, by no means should you try to create a smaller repro case. All you know is that your sample doesn't run.
    8. Post a sample that depends on a resource you don't describe. Be sure your sample reads from your production database. Don't worry, people will figure out your schema.
    ¯\_(ツ)_/¯

  • Struts - example of iterate using a hashtable (key,value)

    I am trying to create a dynamic menu system and each menu group
    is storied within a single hashmap with the name of the menu as the key (e.g. "mainmenu", "adminmenu"). I am having problems understanding the documentation on how to pass the key to select the
    right entry within the hashmap. I have read the following but find
    it confusing. Could someone provide a detailed example?
    http://jakarta.apache.org/struts/struts-logic.html#iterate

    Here's some code to show you what I am doing.
    I will start out with how I am creating the List and the HashMap
        menuList = new ArrayList();
        sqlStatement = "select * from menu where admin = 'Y' ";
        // gets the menu items from the database and builds the menuList
        this.buildMenu( (DBResultSet)db.executeSQL( sqlStatement, args ) );
        // puts the menuList into a HashMap with a key of adminmenu
        //  NOTE: the menuList is actually a collection (list) of beans
        menuMap.setItem ("adminmenu", menuList );
        ...Here's my bean that stores I use to store the HashMap (menuMap).
    import java.util.*;
    public class MenuBO extends BaseBusinessObject
      private HashMap menuMap;
      public MenuBO()
        menuMap = new HashMap();
      public void setItem ( String menuType, List menuList )
        menuMap.put ( menuType, menuList);
      public List getItem( String menuType )
        return  (List)this.menuMap.get( menuType ) ;
      public HashMap getMenuMap ()
        return menuMap;
      public void removeItem ( String menuType)
        menuMap.remove( menuType);
    }And here's my iterate which is not working. I want to single out the value that has a key of "adminmenu" and process that list of menu elements. This is easy to do with scriptlets but I am spending many hours trying to figure out Struts documentation - they need some real world examples if they want Struts to catch on...
    <jsp:useBean id="menuMap" scope="session"
              class="com.benchdogs.webapp.beans.MenuBO"/>
            <logic:iterate id="mapEntry" name="menuMap" property="menuMap">
                <bean:write name="mapEntry" property="key"/>
            </logic:iterate>This example loops through the hashmap and displays the keys. I want to be able to process a specific value based on the key. The value is a List so I would need to do another iterate statement within the master iterate.

  • How can I get keys from Hashtable in the same order?

    Hello, everyone.
    I have a Hashtable containing key-value pairs, I need to get the keys in the same order as I use
    method put(key,value) to save the key-value pairs. But I can only find Hashtable.keys() to fetch the keys in form of Enumeration and when retrieve the keys from the Enumeration,they are not in the original order!
    The following is my code:
    Hashtable ht = new Hashtable();
    ht.put("Name","Harry Bott");
    ht.put("Gender","Male");
    ht.put("Age","25");
    String[] Items = new String[ht.size()];
    Enumeration e = ht.keys();
    int i = 0;
    while(e.hasMoreElements()) {
    Items[i++] =(String)(e.nextElement());
    The Items contains the keys but they are not in the original order.
    Does anyone know how to get the keys from a Hashtable in the same order when they're put?
    Thank you!

    yeah, another solution is to stored keys on a Collection at the same time you put them on the HashMap with its values.
    Then when ur going to retrieve objects from the Map u iterate the Collection that has the ordered keys and use them.

  • Connection object as a key in a hashtable

    Hi,
    I am debugging some code where a Connection object is used as a key in a hashtable. Is this ok? Will the equals() and hashCode method be defined properly for a Connection object?
    Appreciate your help.
    Thanks!

    I am debugging some code where a Connection object is
    used as a key in a hashtable. Is this ok? Will the
    equals() and hashCode method be defined properly for a
    Connection object?First, answer the following question for yourself: how do you defined equality of Connections?
    If a class merely inherits the equals() implementation from Object, then equality is the same as referential identity. If that is Ok for you [which is the case in surprisingly many cases], there is no harm is using Connections as hashtable keys.
    Vlad.

  • Loading a text file on startup into a hashtable

    I am trying to load to seperate textfiles into the same hashtable.
    The textfiles are something like an employee and employee number everything goes in at the same time. How do i load these text files into the hashtable. Also any good tutorials or code samples on hashtables would be greatly appreciated.
    Thanks In Advance

    You read the text files, one line at a time, and break up each line in whatever way you need to. Then you choose the bits to put in the hashtable (key and value) for each line and put those bits into the hashtable.
    http://java.sun.com/docs/books/tutorial/essential/index.html
    http://java.sun.com/docs/books/tutorial/collections/index.html

  • Using Hashtable

    Hello,
    I need to store <key, value> pairs in a hashtable so that I can retrieve it at a later point in time. However, the key is an object of my user defined class. The problem I'm facing is that I can put the <key, value> pair in Hashtable but at a later point in time, I'm not able to retrieve value for a given key and I get a null value always. Is this problem happening because in my user defined class I haven't implemented "equals" method? Or is it happening due to some other reason. I've given below the code snippet of my program.
    class C {
    int val ;
    public C(int v) {
    this.val = v ;
    class Test {
    public static void main(String args[]) {
    Hashtable t = new Hashtable() ;
    t.put(new C(10), new Integer(5)) ;
    /* And here, I get a null object, where as I should get the integer object that
    was put in the hashtable. */
    Integer i = (Integer)t.get(new C(10)) ;
    Thank you,
    Venkatesh

    Hi,
    The problem lies in your put and get.
    t.put(new C(10), new Integer(5)) ;By passing the hashtable key parameter as new C(10), i assume that the JVM is getting a memory allocation/reference.
    t.get(new C(10)) ;Same over here, you are creating another new reference (new instance) different from the put, therefore it return u a null.
    Cheers hope it help.
    ; )

Maybe you are looking for

  • How do I scale strokes in Flash CC?

    I know that in the "Properties" window there is a "Scale" drop-down, but it doesn't work. When I scale in free transform, the stroke doesn't scale unless its in a movieclip.

  • Best way to handle tcMultipleMatchFoundException

    Can any one tell me what is the best way to handle tcMultipleMatchFoundException during Reconciliaiton. One way which i know is to manually correct the data. Apart form is there any way..? Thanks, Venkatesh.

  • Can i replace a p320 cpu with a p360 in a g62-220ca notebook pc ???

    can i replace a p320 cpu with a p360 in a g62-220ca notebook pc ???

  • I can't open RAW (cr2) images from my Canon EOS 650D

    Hey, I use Photoshop CS5 Extended (Version 12.1 x64). I can open the raw-Images (cr2) from my Canon EOS 1000d/Rebel XT but I can not open the RAW-Images (cr2) from my Canon EOS 650D (Rebel T4i). I have installed the latest update for CS5 through the

  • Printing Markups to Postscript file

    I am using the latest Solaris version of Acrobat Reader (7.0.9) to print PDF files.  We use the -toPostscript and -markupsOn command line options to create PostScript files which we then send to lp.  This works fine unless there's a markup on the dra