Reputation: 1382
How can i print an array from a 2d without brackets. Basically am adding first the array with the new values to a 2d with :
books=(Object[][]) Arrays.copyOf(row,2);
whereas books is already initialized as 2d array with :
static Object[][] books=new Object[1][1];
BUT when I try to print the first row from books with :
System.out.println(Arrays.deepToString(books[0])+" ");
it prints me brackets and commas
[asds,asdas,223]
like is suppose to do.
How can i remove those?
Thank you !
Upvotes: 0
Views: 5308
Reputation: 6166
Try this
StringBuilder builder = new StringBuilder();
for (String value : publicArray) {
builder.append(value +",");
// or builder.append(value).append(",");
}
String text = builder.toString();
System.out.print(text);
Upvotes: 1
Reputation: 4691
You can try this
String output ;
for(String s: books[0]){
output = output +s+ ",";
}
output = output.substring(0, output.length()-1);
System.out.print(output);
Upvotes: 0
Reputation: 95958
You can use replaceAll
and simply:
myStr = myStr.replaceAll("\\[|\\]", "");
Upvotes: 2