JAVA字符串操作
1、 public class HelloWorld {
public static void main(String args[]){
String s="daxiong";
System.out.println("Hello,World!"+"lu shenglong"+s);
char c[]={'s','w','q'};
String u=new String(c);
System.out.println(u);
char ch;
ch=u.charAt(1); //字符截取函数
System.out.println(ch);
char cha[]=new char[3];
cha=u.toCharArray();
for(int i=0;i<3;i++)
System.out.print(cha[i]+"、");
}
}
输出:
Hello,World!lu shenglongdaxiong
swq
w
s、w、q、
2、JAVA中“==”比较的是对象的地址,而equals()方法比较的是对象的值。
3、修改字符串 String e="windows".replace('w','q'); 输出:qindoqs
4、trim()方法:该方法返回一个调用字符串的拷贝,将位于字符串前面和后面的空白字符删去,一般形式如下:String s=" hello world ".trim();
输出结果为:hello world
应用实例;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Test {
public static void main(String args[]) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String str;
System.out.println("Enter'stop'to quit;");
System.out.println("Enter Name:");
do{
str=br.readLine();
str=str.trim();
if(str.equals("Tom"))
System.out.println("Tom is 10 years old.");
}while(!str.equals("stop"));
}
}
输出:Enter'stop'to quit;
Enter Name:
Tom
Tom i
相关文档:
网址: http://blog.csdn.net/justinavril/archive/2008/08/06/2775767.aspx
import
java.io.*;
public
class
FileToString {
public
static
String readFile(String fileName)  ......
/**
* @param source: source image file
* @param output: output image file
* @param mode: 0 ratio,1 maxWidth,2 maxHeight,3 maxSide
* @param maxSide: maxWidth, maxHeight or maxSide, different by mode
* @param ratio: ratio if resized by ratio
*/
public static void resizeImage(File ......
个 人 简 历
姓 名:
王志国
性 别:
男
年 龄:
23岁
联系电话:
13124799190
专 业:
计算机技术
工作时间:
一年以上
学 历:
大专
邮 箱:
andy478168@yeah.net
★ 求职意向
工作性质 ......
个 人 简 历
姓 名:
王志国
性 别:
男
年 龄:
23岁
联系电话:
13124799190
专 业:
计算机技术
工作时间:
一年以上
学 历:
大专
邮 箱:
andy478168@yeah.net
★ 求职意向
工作性质 ......
作为Java程序员来说,最痛苦的事情莫过于可以选择的范围太广,可以读的书太多,往往容易无所适从。我想就我自己读过的技术书籍中挑选出来一些,
按照学习的先后顺序,推荐给大家,特别是那些想不断提高自己技术水平的Java程序员们。
一、Java编程入门类
对于没有Java编程经验的Java程序员要入门,随便读什么入门书籍都一 ......