Tring test = "fdsfgds, fdesfds, fds, fds, fdsfds, fdsf, fdsfds, fdsf, fds ";
I want to use "," to separate them and then wrap them. Three lines are displayed, for example, "fdsfgds, fdesfds, fds, here, test is the value returned from the page. The length is not fixed. If more than three entries are separated by commas, the line breaks. If less than three entries are separated, the line breaks.
For test, it can be any length separated by commas.
Public class Num {
Public Num (){
}
Public String [] init (String str) {// convert
String [] s = new String [str. length ()];
S = str. split (",");
Return s;
}
Public void show (String [] s) {// display
Int j = 0;
For (int I = 0; I <s. length; I ++ ){
System. out. print (s [I] + ",");
J ++;
If (j = 3 ){
J = 0;
System. out. println ("");
}
}
}
Public static void main (String [] args ){
String test = "fdsfgds, eee, fdesfds, fds, fds, fdsfds, fdsf, fdsfds, fdsf, fds ";
Num n = new Num ();
String [] s = n. init (test );
N. show (s );
}
}
Output result:
Fdsfgds, eee, fdesfds,
Fds, fds, fdsfds,
Fdsf, fdsfds, fdsf,
Fds,
Author "Mo"