charAt方法

获取字符串某一特定位置的字符:char charAt(int index)

import javax.swing.*;

public class charAt {
 /**
  * @param args
  */
 public static void main(String[] args) {
  // TODO Auto-generated method stub
  String str="Welcome to here!";
  
  String output="The str first char is: "+str.charAt(0)+"\n";
  output+="The str last char is: "+str.charAt(str.length()-1);
  
   JOptionPane.showMessageDialog(null, output,"charAt方法的使用",JOptionPane.INFORMATION_MESSAGE);
   System.exit(0);
 }
}

posted on 2014-10-20 15:21  Iitb  阅读(219)  评论(0)    收藏  举报

导航