本文整理了Java中java.util.Arrays.deepToString()
方法的一些代码示例,展示了Arrays.deepToString()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Arrays.deepToString()
方法的具体详情如下:
包路径:java.util.Arrays
类名称:Arrays
方法名:deepToString
[英]Creates a "deep" String representation of the Object[] passed, such that if the array contains other arrays, the String representation of those arrays is generated as well.
If any of the elements are primitive arrays, the generation is delegated to the other toString methods in this class. If any element contains a reference to the original array, then it will be represented as "[...]". If an element is an Object[], then its representation is generated by a recursive call to this method. All other elements are converted via the String#valueOf(Object) method.
[中]创建传递的对象[]的“深”字符串表示形式,这样,如果数组包含其他数组,也会生成这些数组的字符串表示形式。
如果任何元素是基元数组,则生成将委托给此类中的其他toString方法。如果任何元素包含对原始数组的引用,那么它将表示为“[…]”。如果元素是对象[],则通过递归调用此方法生成其表示形式。所有其他元素都通过字符串#valueOf(Object)方法进行转换。
代码示例来源:origin: stackoverflow.com
String[][] deepArray = new String[][] {{"John", "Mary"}, {"Alice", "Bob"}};
System.out.println(Arrays.toString(deepArray));
//output: [[Ljava.lang.String;@106d69c, [Ljava.lang.String;@52e922]
System.out.println(Arrays.deepToString(deepArray));
代码示例来源:origin: stackoverflow.com
String[][] x = new String[][] {
new String[] { "foo", "bar" },
new String[] { "bazz" }
};
Log.d("this is my deep array", "deep arr: " + Arrays.deepToString(x));
// or
System.out.println("deep arr: " + Arrays.deepToString(x));
// will output: [[foo, bar], [bazz]]
代码示例来源:origin: stackoverflow.com
int[][] array = new int[rows][columns];
System.out.println(Arrays.deepToString(array));
代码示例来源:origin: stackoverflow.com
String[][] aastr = {{"hello", "world"},{"Goodbye", "planet"}};
System.out.println(Arrays.deepToString(aastr));
代码示例来源:origin: stackoverflow.com
public static void main(String[] args) {
int twoD[][] = new int[4][];
twoD[0] = new int[1];
twoD[1] = new int[2];
twoD[2] = new int[3];
twoD[3] = new int[4];
System.out.println(Arrays.deepToString(twoD));
}
代码示例来源:origin: stackoverflow.com
int[] nums = { 1, 2, 3 };
System.out.println(nums);
// [I@xxxxx
System.out.println(Arrays.toString(nums));
// [1, 2, 3]
int[][] table = {
{ 1, },
{ 2, 3, },
{ 4, 5, 6, },
};
System.out.println(Arrays.toString(table));
// [[I@xxxxx, [I@yyyyy, [I@zzzzz]
System.out.println(Arrays.deepToString(table));
// [[1], [2, 3], [4, 5, 6]]
代码示例来源:origin: stackoverflow.com
System.out.println(
java.util.Arrays.toString(
new int[][] {
{ 1 },
{ 2, 3 },
}
)
); // prints "[[I@187aeca, [I@e48e1b]"
System.out.println(
java.util.Arrays.deepToString(
new int[][] {
{ 1 },
{ 2, 3 },
}
)
); // prints "[[1], [2, 3]]"
代码示例来源:origin: stackoverflow.com
import java.util.*;
public class Test {
public static void main(String args[]) {
int[][] twoDim = { {1, 2}, {3, 7}, {8, 9}, {4, 2}, {5, 3} };
Arrays.sort(twoDim, Comparator.comparing((int[] arr) -> arr[0])
.reversed());
System.out.println(Arrays.deepToString(twoDim));
}
}
代码示例来源:origin: stackoverflow.com
String data = "1|apple,2|ball,3|cat";
String[] rows = data.split(",");
String[][] matrix = new String[rows.length][];
int r = 0;
for (String row : rows) {
matrix[r++] = row.split("\\|");
}
System.out.println(matrix[1][1]);
// prints "ball"
System.out.println(Arrays.deepToString(matrix));
// prints "[[1, apple], [2, ball], [3, cat]]"
代码示例来源:origin: stackoverflow.com
Scanner sc = new Scanner(data).useDelimiter("[,|]");
final int M = 3;
final int N = 2;
String[][] matrix = new String[M][N];
for (int r = 0; r < M; r++) {
for (int c = 0; c < N; c++) {
matrix[r][c] = sc.next();
}
}
System.out.println(Arrays.deepToString(matrix));
// prints "[[1, apple], [2, ball], [3, cat]]"
代码示例来源:origin: stackoverflow.com
List<List<String>> ls2d = new ArrayList<List<String>>();
List<String> x = new ArrayList<String>();
x.add("Hello");
x.add("world!");
ls2d.add(x);
System.out.println(Arrays.deepToString(ls2d.toArray()));
代码示例来源:origin: apache/hbase
@Override
public int run(String[] args) throws Exception {
if (args.length < 5) {
System.err.println(USAGE);
return 1;
LOG.info("Running Loop with args:" + Arrays.deepToString(args));
for (int i = 0; i < numIterations; i++) {
LOG.info("Starting iteration = " + i);
System.err.println("Parsing loop arguments failed: " + e.getMessage());
System.err.println(USAGE);
return 1;
代码示例来源:origin: apache/hbase
if (args.length < 5) {
System.err
.println("Usage: Loop <num iterations> " +
"<num mappers> <num nodes per mapper> <output dir> " +
"<num reducers> [<width> <wrap multiplier>]");
return 1;
LOG.info("Running Loop with args:" + Arrays.deepToString(args));
代码示例来源:origin: stackoverflow.com
BigInteger[][] bigIntegerMatrix = zeroMatrix(BigInteger.class, 3, 3);
Integer[][] integerMatrix = zeroMatrix(Integer.class, 3, 3);
Float[][] floatMatrix = zeroMatrix(Float.class, 3, 3);
String[][] error = zeroMatrix(String.class, 3, 3); // <--- compile time error
System.out.println(Arrays.deepToString(bigIntegerMatrix));
System.out.println(Arrays.deepToString(integerMatrix));
System.out.println(Arrays.deepToString(floatMatrix));
代码示例来源:origin: h2oai/h2o-3
for (Model m : ms) {
KMeansModel kmm = (KMeansModel) m;
System.out.println(kmm._output._tot_withinss + " " + Arrays.deepToString(
ArrayUtils.zip(grid.getHyperNames(), grid.getHyperValues(kmm._parms))));
GridTestUtils.extractParams(usedModelParams, kmm._parms, hyperParamNames);
代码示例来源:origin: stackoverflow.com
System.out.println(Arrays.deepToString(table).replaceAll("],", "]," + System.getProperty("line.separator")));
代码示例来源:origin: stackoverflow.com
List<int[]> listOfIntArrays = new ArrayList<int[]>();
listOfIntArrays.add(new int[] { 10, 20, 30 });
listOfIntArrays.add(new int[] { 11, 21, 31 });
listOfIntArrays.add(new int[] { 12, 22, 32 });
int[][] intMatrix = listOfIntArrays.toArray(new int[0][]);
System.out.println(Arrays.deepToString(intMatrix));
代码示例来源:origin: stackoverflow.com
public static void main(String[] args) {
int[][] int2DArray = new int[][] { {11, 12}, { 21, 22}, {31, 32, 33} };
String[][] str2DArray = new String[][]{ {"John", "Bravo"} , {"Mary", "Lee"}, {"Bob", "Johnson"} };
//Prior to Java 8
System.out.println(Arrays.deepToString(int2DArray));
System.out.println(Arrays.deepToString(str2DArray));
// In Java 8 we have lambda expressions
Arrays.stream(int2DArray).flatMapToInt(x -> Arrays.stream(x)).forEach(System.out::println);
Arrays.stream(str2DArray).flatMap(x -> Arrays.stream(x)).forEach(System.out::println);
}
代码示例来源:origin: h2oai/h2o-3
for (Model m : ms) {
DRFModel drf = (DRFModel) m;
System.out.println(
drf._output._scored_train[drf._output._ntrees]._mse + " " + Arrays.deepToString(
ArrayUtils.zip(grid.getHyperNames(), grid.getHyperValues(drf._parms))));
GridTestUtils.extractParams(usedModelParams, drf._parms, hyperParamNames);
代码示例来源:origin: h2oai/h2o-3
for (Key<Model> mKey : mKeys) {
GBMModel gbm = (GBMModel) mKey.get();
System.out.println(gbm._output._scored_train[gbm._output._ntrees]._mse + " " +
Arrays.deepToString(
ArrayUtils
.zip(grid.getHyperNames(), grid.getHyperValues(gbm._parms))));
内容来源于网络,如有侵权,请联系作者删除!