2

単一のキー値で追加/取得するさまざまなレコードを追加しようとしています。

各データ レコードには、次のパラメータが必要です。

public class WebRecord {
        Integer UniqueCustomerID;
        Integer Count; // Number of websites for a given customer

//Repeat the following 'Count' number of times
       { // Each Record for a given Website for the same customer
    String BusinessName, Websites, siteTag;
    Integer uniqueWebID, BusinessTypeID;
       }

}

Web サービスから取得したカウント値に基づいて、そのようなレコードが存在するようにします。以下のようにハッシュマップを使用するつもりでした:

そのデータ構造を HASHMAP に実装する方法を教えてもらえますか? 単一のキー値 UniqueCustomerID を使用して、これらのレコードを入れたり取得したりしたいと考えています。

4

2 に答える 2

1

Javaの概念は苦手ですが、できると思います。

     class WebRecord{ 
          int UniqueCustomerID; 
          int Count;
     } 

     class ContactRecord{ 
        String BusinessName, Websites, siteTag; 
        int uniqueWebID, BusinessTypeID; 
    } 

そしてあなたのJavaファイルで

   MyActivity{ 
            public Map<WebRecord,ArrayList<ContactRecord>> map=new HashMap<WebRecord,ArrayList<ContactRecord>>(); 

        //now create one object of web record

        //create arraylist of ContactRecord depending upon "count" variable's value

        // fill the above both and put into map

            map.put(webRec, arrContact); 
     } 
于 2012-05-05T05:25:49.390 に答える