- class NewDemo1
- {
- public static void sop(String s)
- {
- System.out.println(s);
- }
- public static String myTrim(String s)
- {
- int start=0,end=s.length()-1;
- while(start<=end && s.charAt(start)==' ')
- start++;
- while(start<=end && s.charAt(end)==' ')
- end--;
- return s.substring(start,end+1);
- }
- public static void main(String[] args)
- {
- String m=" abdkd ";
- sop("("+m+")");
- m=myTrim(m);
- sop(m);
- }
- }
复制代码 |
|