2009年1月12日星期一

JAVA's basic knowledge[2]2009-01-12-From

the default value:
int 0
float 0.0
boolean false
引用型 null

private 私有 自己拥有访问权限
public 共有 自由访问
友好 同包内可访问

final class can't be extended.
abstract class can't be created.
if a class which is a son of some class,it must define all of abstract method of its father's class.
if a class has abstract method,it must be a abstract class.

interface body includes constant define and method define withour achieved.

initialize array: int x[]={1,2,3,4,5}

String: it is a class.
Initial method: String()
String([constant String])
String([String])
String(char a[])
String(char a[],startIndex,endIndex)
String(byte[])
String(byte[],startIndex,length)


common method: [String].length()
[String].startsWith()
[String].endsWith()
[String].equals()
[String].toUpperCase()
[String].toLowerCase()
[String].concat([String])//connect two strings
[String].toCharArray()
[String].charAt(index)

to inteager Inteager.parseInt([String])
to long Long.parseLong([String])
to float Float.valueOf([String]).floatValue()
to double Double.valueOf([String]).doubleValue()
to byte[] [String].getBytes()
number to string String.valueOf([number])

search [String].indexOf([String])
[String].indexOf([String],startIndex)

substring [String].substring(startIndex)
[String].substring(startIndex,endIndex)

replace [String].replace(oldChar,newChar)

trim space [String].trim()

analyse string StringTokenizer([String])//is a class.
StringTokenizer([String],delimString)
[StringTokenizer].nextToken()//get next word
[StringTokenizer].hasMoreTokens()
[StringTokenizer].countTokens()

get current time
Date date=new Date();

long time=System.currentTimeMillis();//millisecond counted from Jan 1,0:0,1970

------------------
snigoal@Wang,HUST.Wuhan.China

没有评论: