学习java记录

自己学习java,发现许多新的用处,记录下来。多多复习。

String的用法:根据cracking the coding 习题总结

String str=new String();
str.charAt(i): return the char value at certain index
Arrays.sort(); return the ascend permutation of Char[], byte,double,float, int)
s.toCharArray(); 变成chararray,才能够做很多每一位每一位的操作 1.3,1.4,但是也不见得会有很多很多有用的地方
chararry to string : String s=new String(chararray);
s.indexOf('str')   return -1 没有,返回出现‘str'的第一位

s.replace("s","new");
s.trim();去空格


StringBuffer的使用:会高效,但是需要两步 StringBuffer s=new StringBuffer(); for s.append(xx) s.toString()才能够弄好

Input 读入: 
Scanner s.nextLine() 才能够读取一行有space的string


MD: Char array 直接打出来就可以了。
MD: 直接把int 转换成char 需要考虑其aska码的转换,所以最好不要这么做,最好用string来粘上。
MD: int 不见得是1位,所以说要用String.valueof(int)转换成多位的字符串进行输出才比较合适。





File 相关技巧:
File f = new File("test.text"); 建立新文件
File dir= new File("sdfsdf\");
File file[] allfiles=dir.listFiles(); 返回一个file的数组
File.getabsolutepath();// 返回文件的绝对路径



class: objects that have the same features
Method:don't change the value of the object,
             access the object  unchanged

             mutator change the object


             Shared objects by two variables: 用两个变量同时指向一个object 
int 是一种type ,object的reference才像copy指针;
constructor: 
    public class AA{


                    public AA
                    } 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值