我想将表格转换为一个字符串:
int y [] = {30, 34, 45, 57, 77, 89, 100, 111, 123, 145};
必须是这样的:
String y = 30, 34, 45, 57, 77, 89, 100, 111, 123, 145;
远程代码:
public class GraphLoading extends Activity {
public static int [] y;
int Test;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.loading);
int y [] = {30, 34, 45, 57, 77, 89, 100, 111, 123, 145};
}
public static int[] x = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
}
我必须将该 tablo 转换为字符串,然后才能将其保存到 SD 卡中。
请您粘贴完整的代码吗? (我是业余爱好者)
最佳答案
您可以依赖 Arrays.toString
的实现:
String y1 = Arrays.toString(y).replaceAll("\\[|\\]", "");
否则,您可以循环遍历 int
数组并使用 StringBuilder
附加每个元素。 .
关于java - 如何将表格转为字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22429589/