Virgula

Boas, eu tenho os seguintes métodos e tenho um output com uma vírgula a mais no fim, e não sei como resolver isso… alguém me pode ajudar ?

Output

	public String vertexToEdge(){
		Iterator it = edges.listIterator();
		String s ="";
		String s1="";
		while(it.hasNext()){
			WeightedEdge we= (WeightedEdge) it.next();
			s1 = we.toString()+",";
		}
		return s += s1 ;

	}
	public String toString() {
		String aux="";
		String st="";
		for (int i = 0; i < vertices.size(); ++i) {
			Vertex v = vertices.elementAt(i);
			aux = v.vertexToEdge();
			st+=aux;
		}
		return "["+st+ "]";
	}

Verifique se o item que você está imprimindo é o último antes de concatenar a vírgula. Por exemplo:

if (it.hasNext())
    s1 = we.toString()+",";
else
    s1 = we.toString();

muito obrigado