java - Remove first character if it is comma using array also -
i have wrote code, has string consist email addresses, , going put array getting ,
(comma). here code:
string getemail = "abeywicrema@gmail.com,shan.a@jinasena.com.lk,yasasjayanga@gmail.com"; string[] srr = getemail.split(","); //string tsd = ""; (int = 0; < srr.length; i++) { string string = srr[i]; string[] getemaillist = {",\"" + string + "\""}; system.out.print(getemaillist[0]); }
this output
,"abeywicrema@gmail.com","shan.a@jinasena.com.lk","yasasjayanga@gmail.com"
comma comes in first, need remove first comma, please me resolve this.
first of all, don't need string[]
hold email string
, it's enough in case have string
instead. getemaillist
should of type string
.
second, should reconsider variable's names. getemaillist
suitable name method , not variable, suggest example using currentemail
or that.
last, remove first comma, use sting#substring
or (better solution), when print first time, don't print comma , add in iterations.
Comments
Post a Comment