Home > Back-end >  Long array to turn a list of questions, for help
Long array to turn a list of questions, for help

Time:10-27

 
Public static void main (String [] args)
{
Arr=new long long [] [] 11,41,31,31} {;
//List List=Longs. AsList (arr);
//the List List=Arrays. The stream (arr) boxed () collect (Collectors. ToList ());
List the List=Arrays. AsList (arr);
System. The out. Println (list. Get (0));
}


Desired output first element 11, but the actual output is [J @ 1 c4af82c, I know the List can only add the packing type or a reference type, need to do to output 11?
Great god answer, thank you!

CodePudding user response:

The toString ();

CodePudding user response:

You can refer to
 
Long [] arr={Long. The valueOf (11), and Long. The valueOf (41), Long. The valueOf (31), and Long. The valueOf (31)};
List List=Arrays. AsList (arr);

System. The out. Println (arr [0]).
System. The out. Println (list. Get (0));

CodePudding user response:

The
096 response: refer to the original poster boreas
 
Public static void main (String [] args)
{
Arr=new long long [] [] 11,41,31,31} {;
//List List=Longs. AsList (arr);
//the List List=Arrays. The stream (arr) boxed () collect (Collectors. ToList ());
List the List=Arrays. AsList (arr);
System. The out. Println (list. Get (0));
}


Desired output first element 11, but the actual output is [J @ 1 c4af82c, I know the List can only add the packing type or a reference type, need to do to output 11?
Great god answer, thank you!



 
Public static void main (String [] args) {
Arr=new Long Long [] [] {31 l 11 l, l, 41, 31} l;
List the List=Arrays. AsList (arr);
System. The out. Println (list. Get (0));
}

CodePudding user response:

reference 1st floor Opticalproperti response:
toString ();

Wrong haha
In this way can java8
List List=Arrays. Stream (arr) boxed () collect (Collectors. ToList ());

List Longs=Arrays. AsList (ArrayUtils toObject (arr);

CodePudding user response:

 long arr=new long [] [] 11,41,31,31} {; 
//List List=Longs. AsList (arr);
//the List List=Arrays. The stream (arr) boxed () collect (Collectors. ToList ());
ListSystem. The out. Println (list. Get (0) [0]).

CodePudding user response:

refer to the second floor scene at the beginning of JingChu, reply:

can reference
 
Long [] arr={Long. The valueOf (11), and Long. The valueOf (41), Long. The valueOf (31), and Long. The valueOf (31)};
List List=Arrays. AsList (arr);

System. The out. Println (arr [0]).
System. The out. Println (list. Get (0));

Because your array data without identification, and then the whole list as a data store up, so that the output is referenced

CodePudding user response:

List is not a generic, you see. The get () returns is Object, System. Out calls the superclass Object toString, the output is the memory address;
  • Related