如何将向量转换为逗号分隔的字符串

发布于 2024-10-06 10:44:10 字数 1156 浏览 0 评论 0原文

我在 BlackBerry 应用程序中使用向量来保存电子邮件地址,每个地址一个字符串。当我填充 EditField 时,我得到的输出为: [[email protected]< /a>, [email protected]]

我需要输出如:[电子邮件受保护][电子邮件受保护] 这是因为我需要将这些输出值指定为电子邮件的“收件人”地址。


这里选择的是一个向量。

第一类

obj.call(selected);

这些向量元素分配在第二类中名为 selected2 的另一个向量中

第一类中的第二类调用事件

 public static BasicEditField toadd;

public void call(Vector selected2)
 {
selected = new Vector();
        selected.addElement(selected2);

            for(int i=0;i<selected.size();i++)
            {
                toadd.setText((String) selected.elementAt(i).toString());
}
}

I am using a vector in my BlackBerry app to hold email addresses, one string per address. When I populate an EditField, I get output as : [[email protected], [email protected]]

I need output as : [email protected], [email protected]
This is because I need to assign these output values as a To address for an email.


here selected is one vector.

first class

obj.call(selected);

These vector element assigned in another vector in second class named as selected2

second class call event in first class

 public static BasicEditField toadd;

public void call(Vector selected2)
 {
selected = new Vector();
        selected.addElement(selected2);

            for(int i=0;i<selected.size();i++)
            {
                toadd.setText((String) selected.elementAt(i).toString());
}
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

以歌曲疗慰 2024-10-13 10:44:10

在 call() 方法中,您期望所选向量具有两个元素,而实际上它只有一个元素。 selected 中唯一的元素是向量 selected2。如果要将 selected2 的所有元素分配给 selected ,那么您应该循环 selected2 并将其所有元素放入 selected 中。因此,方法的开头应如下所示:

public void call(Vector selected2)
{
    Vector selected = new Vector();
    for(int i = 0; i < selected2.size(); i++)
    {
        selected.addElement(selected2.elementAt(i));

然后方法的其余部分将正常进行。

In the call() method you are expecting the selected vector to have two elements while in reality it has one. The only element in selected is the vector selected2. If you want to assign all the elements of selected2 to selected then you should loop through selected2 and put all of its elements in selected. So the start of your method should look like this:

public void call(Vector selected2)
{
    Vector selected = new Vector();
    for(int i = 0; i < selected2.size(); i++)
    {
        selected.addElement(selected2.elementAt(i));

And then the rest of the method will proceed normally.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文