I'm using System.out.print
to print an arrayList (cl)
, The code looks like this:
System.out.print("Returning \n");
for(int i = 0 ; i <cl.size(); i++){
if(i+1 == cl.size())
System.out.print(cl.get(i));
else
System.out.print(cl.get(i)+" ,");
}
The output should look like:
Returning 1,2,3....
but it shows up like this:
0 ,5 ,6 Returning
Edit: The problem is not in the order of the elements, but in "Returning" position.
I'm using Windows 8 as an operations system and NetBeans as IDE. Why?!
为了获得类似Returning 1,2,3 ....的输出,首先ArrayList CL应该包含数字1,2 ...,依此类推。其次,尝试使用System.out.println(“ Returning”);。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.