java常用的简单函数

Java Number & Math 类

xxxValue()    //将 Number 对象转换为xxx数据类型的值并返回。

                  //eg:doubleValue() :以 double 形式返回指定的数值。

compareTo();   equals();   valueOf();   toString();   parseInt();

abs();//绝对值           min();    max();   exp()//返回自然数底数e的参数次方

ceil();// 取上>=          log();   sin(弧度值);   cos();   tan();   asin();   acos();   atan();

floor()//取下<=        pow();//次方  sqrt();//算术平方根

rint();//返回与参数最接近的整数

round();//四舍五入

toDegrees();//将参数转化为角度。toRadians(degrees);//将角度转换为弧度。

random();//返回一个随机数。

 

Java Character 类

isLetter();//是否是一个字母    isDigit()//是否是一个数字字符

isWhitespace()//是否是一个空白字符

isUpperCase()//是否是大写字母  isLowerCase()//是否是小写字母

toUpperCase()//指定字母的大写形式  toLowerCase()//Character.toLowerCase('A');指定字母的小写形式

toString();

 

Java String 类

char charAt(int index);  int compareTo(Object o);  int compareTo(String anotherString)

int compareToIgnoreCase(String str);  

String concat(String str);//字符串连接 

static String copyValueOf(char[] data);

static String copyValueOf(char[] data, int offset, int count);

boolean endsWith(String suffix);    boolean equals(Object anObject);

boolean equalsIgnoreCase(String anotherString);

void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin);//将字符从此字符串复制到目标字符数组。

int hashCode();//返回此字符串的哈希码

int indexOf(int ch);     int indexOf(int ch, int fromIndex);//返回第一次出现指定字符处的索引,从指定的索引开始搜索

int indexOf(String str);    int indexOf(String str, int fromIndex);

上面两行中的indexOf 换成 lastIndexOf    又有四个

int lastIndexOf(int ch); int lastIndexOf(int ch, int fromIndex);

 int lastIndexOf(String str);int lastIndexOf(String str, int fromIndex);

String replace(char oldChar, char newChar);//替换所有 oldChar

String replaceAll(String regex, String replacement);

String replaceFirst(String regex, String replacement);//替换此字符串匹配给定的正则表达式的第一个子字符串

String[] split(String regex);  String[] split(String regex, int limit);

boolean startsWith(String prefix);  boolean startsWith(String prefix, int toffset);

char[] toCharArray();

 

 

 

 

 

 

 

 

 

 

 

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值