本帖最后由 枫儿 于 2013-10-13 11:38 编辑
是练习毕老师做去头尾空格的代码,怎么报一堆错 看了半天没看出哪的问题- class StringDemo
- {
-
- public static void sop(String z)
- {
- System.out.println(z);
- }
- public static void main(String[] args)
- {
- String s =" abcd efg ";
- sop("("+s+")");
- s = qtw(s);
- sop("("+x+")");
- public static String qtw(String z)
- {
- int sta = 0,end = z.length()-1;
- while (sta<=end && z.charAt(sta)==' ')
- sta++;
- while(sta<=end && z.charAt(end)==' ')
- end--;
-
- return z.substring(sta,end+1);
- }
-
-
- }
- }
复制代码 |
|