如何在java中将向量转换为字符串? [英] How to convert vector to string in java?

查看:200
本文介绍了如何在java中将向量转换为字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有向量包含 值5 。当我执行 System.out.Println(vectorVariable)时,输出的值是 [5] 。我想将vectorVariable转换为string(不带[])。我尝试过 vectorVariable.toString(),它将其转换为字符串,但仍保留[]。所以我想我真正想要的是第一个作为字符串返回的元素。这怎么可能?

I have a vector and it contains the value 5. When i do System.out.Println(vectorVariable), the value outputted is [5]. I want to convert the vectorVariable to string (without the []). I have tried vectorVariable.toString(), which converts it to a string but it still retains the []. So i guess i what i really want is the first element to be returned as a string. How is this possible?

我想在不带[]的字符串中存储向量的值。

I want to store the value of the vector inside a string without the [].

推荐答案

尝试 System.out.println(vector.get(0))。您正在尝试打印整个矢量,而这只会打印所选索引,在本例中为0。

Try System.out.println(vector.get(0)). You are trying to print the entire vector, whereas this will only print the selected index, in this case 0.

这篇关于如何在java中将向量转换为字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆