2008年8月29日 星期五

字串大小寫轉換

code
package javahomework;

import javax.swing.JOptionPane;
import java.util.StringTokenizer;

public class HW16 {
 public static void main(String args[]) {
  String input = JOptionPane.showInputDialog(null, "");
  StringTokenizer st = new StringTokenizer(input);
  String out = "";
  while (st.hasMoreTokens()) {
   String tmp = st.nextToken();
   StringBuffer buf1 = new StringBuffer(tmp);
   StringBuffer buf2 = new StringBuffer(tmp);
   out = out + buf1.toString().toLowerCase()
     + buf2.toString().toUpperCase() + " ";
  }
  JOptionPane.showMessageDialog(null, out);
 }
}

沒有留言: