用macox系统上的eclipse学习的java 老师是用windows系统上的eclipse教的java 不同系统上吗的eclipse使用有细节的差别,让人郁闷啊啊啊啊啊啊,就因为一个斜杠,服了 1、Mac上的eclipse上使用file类建立一个文件or文件夹 File file=new File("Users/我的名字汉语拼音/Desktop/rupengkejian"); file.mkdir; 死活找不这个文件 2、我又换到windows上面学习 windows上的eclipse使用使用file类建立一个文件or文件夹 File file=new File("d:\w"); file.mkdir; 就可以建一个新的文件夹 3、windows用着用着电脑没有声音了,好生气啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊 又换回mac,才发现mac上使用file类建立一个文件or文件夹 File file=new File("Users/我的名字汉语拼音/Desktop/rupengkejian"); Users前面要加个“/”啊啊啊啊啊啊啊啊啊啊 就差这么一点点,折腾了我一天,好生气啊啊啊啊啊啊啊啊啊啊啊啊

ps: 1、Mac上面的花健=windows上的ctrl键 2、Mac上面建一个txt,先建一个.rtf,打开后用花健+shift+t,自动变为txt格式 3、windows上面的eclipse,可以用f11健立刻运行,也可以ctrl+shift+d,再按j健运动程序

一、这两天学习了8种基本数据类型的包装类

二、学习了String类 public class StringTest1 {

public static void main(String[] args) {
	// TODO Auto-generated method stub
	String userName="aDmin";
	if(userName.equalsIgnoreCase("admin")) {
		System.out.println("right");
	}else {
		System.out.println("wrong");
	}
	
	String userName2="http://www.rupeng.net";
	if(userName2.startsWith("http://")&&(userName2.endsWith(".com")||userName2.endsWith(".cn"))) {
		System.out.println("网址对");
	}else {
		System.out.println("网址错");
	}
	
	String userName3=new String("http://www.rupeng.com");
	if(userName3.startsWith("http://")&&(userName3.endsWith(".com")||userName3.endsWith(".cn"))) {
		System.out.println("网址对");
	}else {
		System.out.println("网址错");
	}
			
}

}

public class StringTest2 {

public static void main(String[] args) {

	String s = "abc123aca";
	System.out.println(s.length());// 获得字符串的长度
	System.out.println(s.charAt(2));// 返回此字符串索引位置为2的字符 给索引返回字符

	System.out.println(s.indexOf('b'));// 返回此字符串中b第一此出现的索引位置 给字符返回索引
	System.out.println(s.indexOf("c1"));// 返回此字符串中c1第一次出现的索引位置 给字符返回索引
	System.out.println(s.lastIndexOf('a'));// 返回此字符串中c最后一次出现的索引位置 给字符返回索引

	System.out.println(s.substring(3));// 返回截取字符串,根据给出的索引位置   给索引返回字符
	System.out.println(s.substring(2, 5));//返回截取字符串,根据给出的索引位置  给索引返回字符

	String s2 = "林志玲.com";
	int dotIndex = s2.indexOf('.');
	System.out.println(dotIndex);
	String name = s2.substring(0, dotIndex);
	System.out.println(name);
	String ext = s2.substring(dotIndex + 1);
	System.out.println(ext);

	String s3 = "[ap2-1122]林志玲.com";
	int index1 = s3.indexOf('[');
	int index2 = s3.indexOf(']');
	System.out.println(index1);
	System.out.println(index2);
	System.out.println(s3.substring(index1+1, index2));

}

}

public class StringTest3 {

public static void main(String[] args) {
	String s = "ADFcddde123";
	System.out.println(s.toLowerCase());
	System.out.println(s.toUpperCase());

	String s1 = s.replace('d', '0');
	System.out.println(s1);

	System.out.println(s.replace("12", "一二"));

	String name = " admin  ";
	name=name.trim();
    System.out.println(name.equals("admin"));
    
    String name2 = " admin  ";
	name2.trim();
    System.out.println(name2.equals("admin"));
    
    String name3="  ad     min ";
    name3=name3.replace(" ", "");
    System.out.println(name3.equals("admin"));
    
    String s2="zhaohan,facai,bizhong";
    String[] names=s2.split(",");
    for(int i=0;i<names.length;i++) {
    	System.out.println(names[i]);
    }
}

}

public class StringBufferTest {

public static void main(String[] args) {
	// TODO Auto-generated method stub
	String s1="aaaa";
	String s2="bbbb";
	String s3="吃吃吃吃吃吃吃";
	String s4="dddd";
	StringBuffer sb=new StringBuffer();

// sb.append(s1); // sb.append(s2); // sb.append(s3); // sb.append(s4); sb.append(s1).append(s2).append(s3).append(s4); System.out.println(sb.toString());

}

}

public class Person { //StringBuffer原理 public Person speak() { System.out.println("speak chinese"); return this; } public Person sing() { System.out.println("sing a song"); return this; } public Person sleep() { System.out.println("I am tied,i wanna sleep"); return this; }

public static void main(String[] args) {
	// TODO Auto-generated method stub
	Person p=new Person();
	p.speak();
	p.sing();
	p.sleep();
	
	Person pp=new Person();
	// Person pp=new Person(); 
	//pp.speak();
	//Person ppp=pp.speak();
	//ppp.sing();
	//Person.pppp=ppp.sing();
	pp.speak().sing().sleep();
			
}

}