Display in a Messagedialog the contents of List<String> message = new Arraylist<String>();

Asked

Viewed 47 times

0

Good night, I need to display the contents of the message array in a Message Dialog:

List<String> mensagem = new ArrayList<String>();

In the course of code I add some text to the array as:

mensagem.add(" o metodo" + m1.getName()+" precisa ser alterado\n");

mensagem.add(" a classe" + m1.getName()+" precisa ser alterado\n");

I have the method that returns her:

public String getMsg() {
    return mensagem.toString();
}
MessageDialog.openInformation(window.getShell(), "Teste", vs.getMsg());

And when I display it in the Messagedialog it appears with a bracket at the beginning and at the end , moreover when I have more than one term they appear separated by commas. Like : inserir a descrição da imagem aqui

I would like not appear the [] and neither the commas , but looking at the cogido is not possible to see where this information comes from.

Could someone explain to me how to remove this information?

1 answer

0


When you perform:

 return mensagem.toString();

You return a string from the Array you created, to print the messages you will need to change its function to:

public String getMsg() {
    String message = "";
    for(String item : mensagem) {
        message += item;
    }
   return message;
}
  • Okay, it worked. Thank you

  • Mark my answer as sure.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.