-1

I have the following code:

     public static void closestInSubnet(int[][] adjlist, short[][] addrs, int src, short[][] queries) {
     // TODO
     
     List<String> address = ToList(addrs);
     List<String> quer = ToList(queries);
     
     for (String i : address) {
         System.out.println(i);
     }
     
 }

     public static List<String> ToList(short[][] preList) {
     List<String> list = new ArrayList<String>();
     
     for (short[] i : preList) {
         list.add(i.toString());
     }

     return list;
 }

I want it to be printing out the lists converted to Strings however I am getting the following in console:

[S@7637f22
[S@4926097b
[S@762efe5d
[S@5d22bbb7
[S@41a4555e
[S@3830f1c0
[S@39ed3c8d
[S@71dac704
[S@123772c4

I'm sure there is a quick fix for this any help would be great. thanks

1 Answers1

2

You are created a list of arrays. You are now looping through the list and attempting to print the list in one go. What you are seeing is the object ID of the arrays.

You need to add an inner loop to print the individual elements of each array.

Tarik
  • 10,810
  • 2
  • 26
  • 40