aspose file tools*
The moose likes Java in General and the fly likes Error #: 361 : variable required, but value found Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Error #: 361 : variable required, but value found" Watch "Error #: 361 : variable required, but value found" New topic
Author

Error #: 361 : variable required, but value found

Rashid Hafeez Khokhar
Greenhorn

Joined: Oct 22, 2004
Posts: 1
Hi,
if we have the inPut={"A","B","A","C","B"} then we want the non-repeated array with element as outPut={"A","B","C"}

The following code showing the "Error #: 361 : variable required, but value found at line 12, column 34".

Vector inPut=new Vector();
Vector outPut=new Vector();
int m=0;
for(int i=0; i < inPut.size(); i++){

if(inPut.elementAt(i) == null) continue;
else{

for(int j=i+1; j < inPut.size(); j++){

if(inPut.elementAt(i) == inPut.elementAt(j))

// Error Line=12 inPut.elementAt(i) = null;

} // inner for
} // else
outPut.elementAt(m) = inPut.elementAt(i);
System.out.println("OutPut=" +outPut.elementAt(m));
m++;
} // outer for


Kind Regards

Rashid.
rhkhokhar@hotmail.com
Greg T Robertson
Ranch Hand

Joined: Nov 18, 2003
Posts: 91
Vector implements List I thikn you are doing a lot of work you don't have to. List (and thus vector) has a contains method which will tell you if the vector already contains what you have). for instance if (!output.contains(element)) //add it here

Regarding the original question i'm not sure what to tell you, except you may want to add some code formatting tags to make it easier to read
Greg T Robertson
Ranch Hand

Joined: Nov 18, 2003
Posts: 91
Couple of things here
1) inPut.elementAt(i) gives you an object that you can't set equal to seomthing if you want to set the value of an object at a particular position in the array do a vector.setElementAt(index, object);

2) The second for loop is not necessary to see if the vector contains the object you are looking for it's easy enough to say outPut.contains(inPut.elementAt(i));

3) The M is not required either as you should be able to just say outPut.add(object) - unless of course you have to maintain the same "number" position in the array for some reason

 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Error #: 361 : variable required, but value found