码迷,mamicode.com
首页 > 编程语言 > 详细

把数组变换成字符串

时间:2017-09-21 22:25:01      阅读:152      评论:0      收藏:0      [点我收藏+]

标签:[]   变换   ++   i++   ring   字符串   length   表达   else   

  int[] arr = {1,2,3};

  for(int i=0;i<arr.length();i++){

    String temp  = "[";

    if(temp==arr.length()-1){

    temp = temp+arr[i]+"]"    

    }else{

    temp = temp+arr[i]+", "     

    }

    //如果将上面的判断换成正则表达式的话

    //temp = temp+((i==arr.length()?arr[i]+"]":arr[i]+", "));  

  }

  System.oout.println(temp);

把数组变换成字符串

标签:[]   变换   ++   i++   ring   字符串   length   表达   else   

原文地址:http://www.cnblogs.com/blue-crystal/p/7571492.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!