1、java.lang包.pptVIP

  • 1
  • 0
  • 约1.33万字
  • 约 36页
  • 2016-08-23 发布于河南
  • 举报
1、java.lang包

方法 说明 StringBuffer insert(String s) 在指定位置插入布尔值的字符串表示 int length( ) 确定 StringBuffer 对象的长度 void setCharAt(int pos, char ch) 使用 ch 指定的新值设置 pos 指定的位置上的字符 String toString( ) 转换为字符串形式 StringBuffer reverse() 保留 StringBuffer 对象中的字符 StringBuffer delete(int start, int end) 此方法将删除调用对象中从 start 位置开始直到 end 指定的索引 – 1 位置的字符序列 StringBuffer deleteCharAt(int pos) 此方法将删除 pos 指定的索引处的字符 StringBuffer replace(int start, int end, String s) 此方法使用一组字符替换另一组字符。将用替换字符串从 start 指定的位置开始替换,直到 end 指定的位置结束 String类 创建后 直接修改 不变性的概念 解决方法 StringBuffer 类 String 的对等类 表示可增加和可编 写字符的可变序列 将字符插入到字符串中间 或附加到字符串末尾 演示:示例 8 StringBuffer 类的用法 使用 StringBuffer 类的方法,如 append()、insert()、replace()、setCharAt() 和 toString() public class StringBuf { /** 构造方法 */ protected StringBuf() { } public static void main(String []args) { StringBuffer buf = new StringBuffer(Java); buf.append(“ Guide Ver1/”); buf.append(3); int index = 5; buf.insert(index, Student ); index = 23; buf.setCharAt(index, .); int start = 24; int end = 25; buf.replace(start, end, 4); String s = buf.toString(); //转换为字符串 System.out.println(s); } } Math 类 数字运算的方法 几何函数的方法 静态方法 子 类 最终类 方法 说明 double sin (double numvalue) 计算角 numvalue 的正弦值 double cos (double numvalue) 计算角 numvalue 的余弦值 double pow (double a, double b) 计算 a 的 b 次方 double sqrt (double numvalue) 计算给定值的平方根 int abs (int numvalue) 计算 int 类型值 numvalue 的绝对值,也接收 long、float 和 double 类型的参数 double ceil (double numvalue) 返回大于等于 numvalue 的最小整数值 double floor (double numvalue) 返回小于等于 numvalue 的最大整数值 int max(int a, int b) 返回 int 型值 a 和 b 中的较大值,也接收 long、float 和 double 类型的参数 int min(int a, int b) 返回 a 和 b 中的较小值,也可接收 long、float 和 double 类型的参数 演示:示例 9 Math 类的用法 使用 Math 类的方法,如 ceil()、floor() 和 round() public class MathDemo { /** 构造方法 */ protected MathDemo() { } /** main 方法演示 Math 类的不同方法 * @param

文档评论(0)

1亿VIP精品文档

相关文档