can anyone tel wat error i made in the below code..I want to assign the list of strings stored in one variable to one string array.wordlist contains list of variables.

for (int s=0; s <=wordlist; s++)
	    {
		String wordlisting[s]=new wordlist;
		System.out.println(wordlisting[s]);
            }

error

D:\program files\Java\jdk1.5.0\bin>javac Main.java
Main.java:86: ']' expected
String wordlisting[s]=new wordlist;
^
1 error

The whole for statement is wrong!

Can you explain what you trying to achive?

want to stroe the variable which contains the list of strings to one array..

Do you have any specific reason to change from List to Array? I think that data are better kept in List which can dynamicaly grow then in fix size array...

i want to check for the list of duplicates in the variable...
Can i add the strings to the array and form a set to check for dups..
Give ur suggestions

if( m.group(2).equalsIgnoreCase("NN"))
 {
      list = m.group(1);
      Set<String> s = new HashSet<String>();	
      if(!s.add(list))
  	System.out.println("Dups" +list);   	
         return list;
 }

list is a variable tat contains list of strings.
I want to check duplicates in that variable.
but here its not printing any..
Can anyone figure or suggs pls.

code

import java.io.*;
import java.util.*;
class Duplicate
{
 public static void main(String args[]){
	Set<String> s = new HashSet<String>();
	String arr[]={"hi","hello","hi","hello","how","are"};
        for(int i=0;i<arr.length;i++)
	{
        	if(!s.add(arr[i]))
	 	System.out.println("duplicates are" +arr[i]);
	}
  }
}

D:\program files\Java\jdk1.5.0\bin>java Duplicate
duplicates arehi
duplicates arehello

while passing list variable in the previous code its not printing anything.

if( m.group(2).equalsIgnoreCase("NN"))
 {
      list = m.group(1);
      Set<String> s = new HashSet<String>();    
      if(!s.add(list))
      System.out.println("Dups" +list);       
         return list;
 }

list is a variable tat contains list of strings.
I want to check duplicates in that variable.
but here its not printing any..
Can anyone figure or suggs pls.

"list" looks to be a single string here. Not sure why you call it a list. Also, you are creating a new Set before you add "list" to it. It's not going to contain dupes if you only added one thing to it. Not sure why are you returning from the method in the middle of your if statement either.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.