当前位置: 首页 > news >正文

国内最好的在线网站建设制作网页无法铺平

国内最好的在线网站建设,制作网页无法铺平,广州市增城区建设局网站,wordpress archlinuxJava核心类库篇2——lang 1、Object 该类是所有类的父类#xff0c;每个类都使用它作为超类#xff0c;没有任何属性 方法声明功能介绍Object()使用无参方式构造对象boolean equals(Object obj)用于判断调用对象是否与参数对象相等。 该方法默认比较两个对象的地址是否相等…Java核心类库篇2——lang 1、Object 该类是所有类的父类每个类都使用它作为超类没有任何属性 方法声明功能介绍Object()使用无参方式构造对象boolean equals(Object obj)用于判断调用对象是否与参数对象相等。 该方法默认比较两个对象的地址是否相等int hashCode()用于获取调用对象的哈希码值(内存地址的编号)String toString()用于获取调用对象的字符串形式 该方法默认返回的字符串为包名.类名哈希码值的十六进制Class getClass()用于返回调用对象执行时的Class实例反射机制使用 equals与 运算符的结果一致若希望比较两个对象的内容则需要重写该方法。 若该方法被重写后则应该重写hashCode方法来保证结果的一致性hashCode若两个对象调用equals方法相等则各自调用该方法的结果必须相同若两个调用对象equals方法不相等则各自调用该方法的结果应该不相同为了使得该方法与equals方法保持一致需要重写该方法toString为了返回更有意义的数据需要重写该方法 使用print或println打印引用或字符串拼接引用都会自动调用该方法 2、包装类 基本类型并不具有对象的性质为了与其他对象“接轨”就出现了包装类型如我们在使用集合类型Collection时就一定要使用包装类型而非基本类型它相当于将基本类型“包装起来”使得它具有了对象的性质并且为其添加了属性和方法丰富了基本类型的操作。 基本类型包装类booleanjava.lang.Booleancharjava.lang.Characterbytejava.lang.Byteshortjava.lang.Shortintjava.lang.Integerlongjava.lang.Longfloatjava.lang.Floatdoublejava.lang.Double 基本类型的优势数据存储相对简单运算效率比较高包装类的优势有的容易比如集合的元素必须是对象类型满足了java一切皆是对象的思想声明方式不同基本类型不适用new关键字而包装类型需要使用new关键字来在堆中分配存储空间存储方式及位置不同基本类型是直接将变量值存储在堆栈中而包装类型是将对象放在堆中然后通过引用来使用初始值不同基本类型的初始值如int为0boolean为false而包装类型的初始值为null使用方式不同基本类型直接赋值直接使用就好而包装类型在集合如Collection、Map时会使用到 2.1、包装类的装箱拆箱 public class Test {public static void main(String[] args) {//自动装箱拆箱int a10;Integer integera;int binteger;System.out.println(a);System.out.println(integer);System.out.println(b);//手动装箱拆箱int a110;Integer integer1new Integer(a1);int b1integer1.intValue();System.out.println(a);System.out.println(integer);System.out.println(b);} }2.2、包装类与字符串的转换 public class Test {public static void main(String[] args) {//解析字符串String a100;//Java为了提高拆装箱效率在执行过程中提供了一个缓存区对象池【类似于常量数组】//如果传入的参数是-128参数127会直接去缓存查找数据如果有久直接产生如果没有就隐式调用new方法产生System.out.println(Integer.parseInt(a));String b100.2;System.out.println(Float.parseFloat(b));String ctrue;System.out.println(Boolean.parseBoolean(c));//转为字符串Integer d100;System.out.println(d.toString());} }3、Math 3.1、属性 属性介绍Math.PIπMath.Ee public class Test {public static void main(String[] args) {System.out.println(math属性);System.out.println(Math.PI);System.out.println(Math.E);} }math属性 3.141592653589793 2.7182818284590453.2、三角函数方法 方法声明功能介绍public static double sin(double radians)正弦函数public static double cos(double radians)余弦函数public static double tan(double radians)正切函数public static double toRadians(double degree)度转换成弧度public static double toDegree(double radians)弧度转换成度public static double asin(double a)反正弦public static double acos(double a)反余弦 3.2、指数函数方法 方法声明功能介绍public static double exp(double x)e^xpublic static double log(double x)ln(x)public static double log10(double x)log 10(x)public static double pow(double a,double b)a^bpublic static double sqrt(double x)√x 3.3、取整方法 方法声明功能介绍public static double ceil(double x)天花板的意思就是逢余进一public static double floor(double x)地板的意思就是逢余舍一 public class Test {public static void main(String[] args) {double a2.5;System.out.println(Math.ceil(a));System.out.println(Math.floor(a));} }3.0 2.03.4、min、max、abs方法 方法声明功能介绍public static int abs(int a)返回一个数的绝对值public static int min(int a, int b)返回两个数的最小值public static int max(int a, int b)返回两个数的最大值public static double random()生成大于等于0.0且小于1.0的double型随机数 public class Test {public static void main(String[] args) {int a5;int b9;System.out.println(Math.max(a,b));System.out.println(Math.min(a,b));int c-9;System.out.println(Math.abs(c));System.out.println(Math.random());} }9 5 9 0.307415504617393754、String String类被final关键字修饰意味着String类不能被继承并且它的成员方法都默认为final方法字符串一旦创建就不能再修改String类实现了Serializable、CharSequence、 Comparable接口String实例的值是通过字符数组实现字符串存储的 4.1、构造方法 方法声明功能介绍String str“hello world!”字面量创建public String()无参构造方法public String(String original)用已知的字符串value创建一个String对象public String(char value[])用字符数组value创建一个String对象public String(char value[], int offset, int count)用字符数组chars的offset开始的count个字符创建一个String对象public String(byte bytes[])用byte数组values创建一个String对象 常用的为字面量创建 4.2、字符串长度 方法声明功能介绍public int length()字符串的长度 public class Test {public static void main(String[] args) {String strhello world!;System.out.println(str.length());} } 12 4.3、字符串中指定位置的字符 方法声明功能介绍public char charAt(int index)字符串中指定位置的字符 public class Test {public static void main(String[] args) {String strhello world!;System.out.println(str.charAt(1));} } e 4.4、提取子串 方法声明功能介绍public String substring(int beginIndex)从beginIndex位置起从当前字符串中取出剩余的字符public String substring(int beginIndex, int endIndex)从beginIndex位置起从当前字符串中取出到endIndex-1位置的字符 public class Test {public static void main(String[] args) {String strhello world!;System.out.println(str.substring(2));System.out.println(str.substring(2,4));} } llo world! ll 4.5、字符串比较 方法声明功能介绍public int compareTo(String anotherString)对字符串内容按字典顺序进行大小比较public int compareToIgnore(String anotherString)同上忽略大小写public boolean equals(Object anotherObject)比较当前字符串和参数字符串public boolean equalsIgnoreCase(String anotherString)比较字符串忽略大小写 public class Test {public static void main(String[] args) {String stra;String str1A;System.out.println(str.compareTo(str1));System.out.println(str.compareToIgnoreCase(str1));System.out.println();System.out.println(str.equals(str1));System.out.println(str.equalsIgnoreCase(str1));} } 32 0false true 4.6、字符串连接 方法声明功能介绍public String concat(String str)将字符串str连接到当前字符串的后面效果等价于 与直接一致 4.7、字符串中单个字符查找 方法声明功能介绍public int indexOf(int ch/String str)查找当前字符串中字符或子串返回第一次出现的位置public int indexOf(int ch/String str, int fromIndex)从fromIndex开始查找当前字符串中字符或子串返回第一次出现的位置public int lastIndexOf(int ch/String str)倒着查找当前字符串中字符或子串返回第一次出现的位置public int lastIndexOf(int ch/String str, int fromIndex)倒着从fromIndex开始查找当前字符串中字符或子串返回第一次出现的位置 public class Test {public static void main(String[] args) {String strhello world!;System.out.println(str.indexOf(o));System.out.println(str.lastIndexOf(o));} } 4 7 4.8、字符串大小写转换 方法声明功能介绍public String toLowerCase()所有字符转换成小写public String toUpperCase()所有字符转换成大写 public class Test {public static void main(String[] args) {String strHello World!;System.out.println(str.toUpperCase());System.out.println(str.toLowerCase());} } HELLO WORLD! hello world! 4.9、字符串中字符的替换 方法声明功能介绍public String replace(char oldChar, char newChar)用字符newChar替换当前字符串中所有的oldChar字符public String replaceFirst(String regex, String replacement)用字符replacement的内容替换当前字符串中遇到的第一个和字符串regex相匹配的子串public String replaceAll(String regex, String replacement)用字符replacement的内容替换当前字符串中遇到的所有和字符串regex相匹配的子串 public class Test {public static void main(String[] args) {String strHello World!;System.out.println(str.replace(o,v));//正则表达式会独立开新篇} } Hellv Wvrld! 4.10、其他类方法 方法声明功能介绍public String trim()截去字符串两端的空格但对于中间的空格不处理public boolean startsWith(String prefix)判断当前字符串是否以指定字符串开始public boolean endWith(String suffix)判断当前字符串是否以指定字符串结束public contains(String str)判断参数s是否被包含在字符串中public String[] split(String str)将str作为分隔符进行字符串分解 public class Test {public static void main(String[] args) {String str Hello World! ;System.out.println(str.trim());System.out.println(str.contains(ello));System.out.println(str.startsWith( Hello));System.out.println(str.endsWith(World! ));} } Hello World! true true true 4.11、字符串转为基本类型 方法声明功能介绍public static byte parseByte(String s)String转为bytepublic static short parseShort(String s)String转为shortpublic static short parseInt(String s)String转为intpublic static long parseLong(String s)String转为longpublic static float parseFloat(String s)String转为floatpublic static double parseDouble(String s)String转为double 4.12、基本类型转为字符串 方法声明功能介绍public static String valueOf(char data[])byte转Stringpublic static String valueOf(char data[], int offset, int count)char[]转Stringpublic static String valueOf(boolean b)boolean转Stringpublic static String valueOf(char c)char转Stringpublic static String valueOf(int i)int转Stringpublic static String valueOf(long l)long转Stringpublic static String valueOf(float f)float转Stringpublic static String valueOf(double d)double转String 4.13、StringBuffer StringBuffer类的对象能够被多次的修改并且不产生新的未使用对象 属于线程安全的类效率比较低 4.13.1、构造函数 方法声明功能介绍public StringBuffer()构造一个字符串缓冲区其中没有字符初始容量为16个字符public StringBuffer(CharSequence seq)构造一个包含与指定字符相同的字符串缓冲区public StringBuffer(int capacity)构造一个字符串缓冲区其中没有字符但是包含指定的初始容量capacitypublic StringBuffer(String str)构造一个指定字符串内容的字符串缓冲区 4.13.2、方法 方法声明功能介绍public StringBuffer append(String str)将指定的字符串追加到此字符序列public StringBuffer append(StringBuffer sb)将指定的内容附加StringBuffer到此序列public int capacity()返回当前容量public char charAt(int index)返回char指定索引处的此序列中的值public StringBuffer delete(int start, int end)删除此序列的子字符串中的字符public StringBuffer deleteCharAt(int index)删除指定位置字符public int indexOf(String str)指定子字符串第一次出现的字符串中的索引public StringBuffer insert(int offset, String str)将字符串插入此字符序列public int length()返回该字符串的长度public StringBuffer replace(int start, int end, String str)用指定的字符替换此序列的子字符串中的字符Stringpublic StringBuffer reverse()此字符序列的反向替换public void setCharAt(int index, char ch)指定索引处的字符设置为chpublic void setLength(int newLength)设置字符序列的长度public String toString()此序列中数据的字符串 4.14、StringBuilder StringBuilder类的对象能够被多次的修改并且不产生新的未使用对象属于非线程安全的类效率比较高 4.14.1、构造方法 方法声明功能介绍public StringBuilder()构造一个没有字符的字符串构建器初始容量为16个字符public StringBuilder(CharSequence seq)构造一个包含与指定的相同字符的字符串构建器public StringBuilder(int capacity)造一个没有字符的字符串构建器由构capacity参数指定的初始容量public StringBuilder(String str)构造一个初始化为指定字符串内容的字符串构建器 4.14.2、方法 方法声明功能介绍public StringBuilder append(String str)将指定的字符串附加到此字符序列public StringBuilder append(StringBuffer sb)将指定 StringBuffer追加到这个序列public int capacity()当前容量public char charAt(int index)获取指定索引位的字符public StringBuilder delete(int start, int end)删除指定索引间的字符串public StringBuilde deleteCharAt(int index)删除指定位置的字符public int indexOf(String str)指定子字符串第一次出现的字符串内的索引public StringBuilder insert(int offset, String str)将字符串插入到此字符序列中public int length()返回长度public StringBuilder replace(int start, int end, String str)用指定的String中的字符替换此序列的子字符串中的Stringpublic StringBuilder reverse()字符串顺序颠倒public void setCharAt(int index, char ch)指定索引处的字符设置为chpublic void setLength(int newLength)设置字符序列的长度public String substring(int start)返回指定位置后的字符串public String toString()此顺序中的数据的字符串 5、System 主要用于获取系统的属性数据 5.1、属性 属性介绍PrintStreamerr标准错误输出流InputStreamin标准输入流PrintStreamout标准输出流 5.2、方法 方法声明功能介绍public static void arraycopy(Object src, int srcPos, Object dest, int destPos, int length)将指定源数组从指定位置复制到目标数组的指定位置public static long currentTimeMillis()返回当前时间以毫秒为单位static void exit(int status)终止当前运行的Java虚拟机public static void gc()提醒运行垃圾回收器public static String getenv(String name)获取指定环境变量的值static Properties getProperties()获取当前的系统属性static String getProperty(String key)获取指定键指示的系统属性static String lineSeparator()系统相关的行分隔符字符串static void setProperties(Properties props)将系统属性设置为Properties参数static void setSecurityManager(SecurityManager s)设置系统安全性 public class Test {public static void main(String[] args) {System.out.println(System.currentTimeMillis());System.out.println(System.getenv());} }
http://www.zqtcl.cn/news/435925/

相关文章:

  • 建设银行如何招聘网站网站开发转包协议
  • 主流网站建设服务器有哪些电商平台
  • 网站与数据库的联系wordpress改为中文
  • 如何不让百度收录网站wix和wordpress比较
  • php开源网站 网上商城网站建设公司做销售好不好
  • 网站开发学哪种语言网站加水印
  • 帮人家做网站维护女性手机网站模板
  • 给一个企业做网站苏州网站备案查询
  • 域名备案期间怎么做网站广告投放行业
  • wordpress站内搜索统计网站突然不收录了
  • 网站源码小千个人网做网页设计一个月能挣多少
  • 贵州省建设厅公示网站广州seo网站推广费用
  • 旅游网站建设前期分析公众号制作多少钱
  • 延庆长沙网站建设怎样下载门户网站
  • flash 网站建设建设带数据搜索的网站
  • 设计网站网站名称云主机 小型网站
  • 网站建设方案书 模版公司制作网站收费标准
  • 福州企业网站html模板网站模板下载
  • 湛江自做网站城乡住建局官网
  • 广东网站建设找自己做网站还有出路吗
  • wordpress后台管理地址更改班级优化大师怎么用
  • 电脑网站开发学习产品怎么做市场推广
  • 上海市网站建设公叿目前流行的app网站开发模式
  • 企业手机网站建设效果wordpress栏目链接地址
  • 产品经理做网站网络公司名字免费起名大全
  • 做得比较好的公司网站kol营销
  • 百度指数分析平台长春seo优化企业网络跃升
  • 如何免费做网站域名wordpress 赚钱
  • 苏州市住房建设局网站首页温州网站设计公司
  • 网站模板哪个好用汕头建设工程总公司