我刚刚开始学习Java,我想尝试使用数组来表示大的负数.
假设我有一个数组
[-2, 0, -5] and this represents the number -502
Run Code Online (Sandbox Code Playgroud)
我尝试过使用StringBuilder,但是打印出来了
-50-2
Run Code Online (Sandbox Code Playgroud)
这是我现在的代码.有没有办法让它可以附加第一个否定,然后在我构建一个新的String时跳过其余的底片?
StringBuilder sb = new StringBuilder();
for(int x = arr.length-1; x>=0; x--){
sb.append(arr[x]);
}
String check = sb.toString();
System.out.println(check);
Run Code Online (Sandbox Code Playgroud)