Results 1 to 4 of 4
Thread: ArrayList issue
- 03-14-2011, 03:49 AM #1
Member
- Join Date
- Mar 2011
- Posts
- 29
- Rep Power
- 0
ArrayList issue
hi,
but it does not make any comparisona1.add("every");
a1.add("bobs");
a1.add("three");
a2.add("ev");
a2.add("ob");
for (String bigram1 : a2) {
for (String words : a1) {
if (words.contains(bigram1)) {
if(test.containsKey(bigram1)){
test.get(bigram1).add(words);
}
else {
test.put(bigram1, new ArrayList<String>(a1));
}
}
}
}
System.out.println(test);
{ev=[every, bobs, three], ob=[every, bobs, three]}
displayed all values. what is wrong in this codes?thanks.
- 03-14-2011, 05:01 AM #2
Recommended reading:
Code Conventions for the Java(TM) Programming Language: Contents
How To Ask Questions The Smart Way
SSCCE : Java Glossary
We haven't the slightest clue what the variable test represents. This does look wrong though:dbJava Code:test.put(bigram1, new ArrayList<String>(a1));
edit And use code tags, not quote tags, to post code.
- 03-14-2011, 05:03 AM #3
Member
- Join Date
- Mar 2011
- Posts
- 29
- Rep Power
- 0
hi db,
thank for the reply
HashMap<String, ArrayList<String>> test = new HashMap<String, ArrayList<String>>();
ArrayList <String> a1 = new ArrayList<String>();
ArrayList <String> a2 = new ArrayList<String>();
test represent hashmap
and a1 and a2 represent 2 arraylists
- 03-14-2011, 10:02 AM #4
Similar Threads
-
sorting arraylist based on another arraylist
By busdude in forum New To JavaReplies: 4Last Post: 02-07-2011, 11:48 AM -
how to add Arraylist filter for a jsp page showing results from a servlet-Arraylist
By alok_sharma in forum Java ServletReplies: 7Last Post: 11-22-2010, 01:26 PM -
Printing contents of Arraylist -- strange issue
By YeeP in forum New To JavaReplies: 19Last Post: 08-10-2010, 08:36 AM -
ArrayList issue
By tomrobpowell in forum EclipseReplies: 2Last Post: 05-08-2010, 07:04 AM -
Java Project Trouble: Searching one ArrayList with another ArrayList
By BC2210 in forum New To JavaReplies: 2Last Post: 04-21-2008, 11:43 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks