摘要: public class Application { public static void main(String[] args) { //StringBuffer和StringBuilder的使用(一般使用StringBuilder) //StringBuffer和StringBuilder 与S 阅读全文
posted @ 2023-02-15 16:05 惊鸿宴远赴人间 阅读(20) 评论(0) 推荐(0)
摘要: public class Application { public static void main(String[] args) { String str="this is a text"; //1 将str中的单词单独获取出来 String[] s = str.split(" "); for ( 阅读全文
posted @ 2023-02-15 12:49 惊鸿宴远赴人间 阅读(20) 评论(0) 推荐(0)
摘要: public class Demo01 { public static void main(String[] args) { String name="hello";//“hello”常量存储在字符串池中,字符串池在方法区中,字符串字面值可以共享 name="张三";//"张三"赋给name变量。给 阅读全文
posted @ 2023-02-15 12:49 惊鸿宴远赴人间 阅读(85) 评论(0) 推荐(0)
摘要: public class Demo01 { public static void main(String[] args) { Integer integer1 = new Integer(100); Integer integer2 = new Integer(100); System.out.pr 阅读全文
posted @ 2023-02-14 13:04 惊鸿宴远赴人间 阅读(30) 评论(0) 推荐(0)
摘要: public class Demo01 { public static void main(String[] args) { //基本类型和字符串之间的转换 // 1.基本类型转换为字符串 int num1=15; //1.使用+ ,后面拼接字符串 String s1=num1+" "; Syste 阅读全文
posted @ 2023-02-14 12:37 惊鸿宴远赴人间 阅读(22) 评论(0) 推荐(0)
摘要: public class Demo01 { public static void main(String[] args) { //装箱:基本类型转换为引用类型 int num1=10; Integer integer1 = new Integer(num1);//第一种方法 Integer inte 阅读全文
posted @ 2023-02-14 12:15 惊鸿宴远赴人间 阅读(22) 评论(0) 推荐(0)
摘要: public class Student { private String name; private int age; public Student() { } public Student(String name, int age) { this.name = name; this.age = 阅读全文
posted @ 2023-02-14 10:17 惊鸿宴远赴人间 阅读(17) 评论(0) 推荐(0)
摘要: public class Application { public static void main(String[] args) { String str1="a"+1+2;//a12 字符串在前,后面均视为字符串 int str2='a'+1+2;//100 单个字符会转换为具体的值:a=97, 阅读全文
posted @ 2023-02-10 16:07 惊鸿宴远赴人间 阅读(10) 评论(0) 推荐(0)
摘要: //自定义的异常类public class MyException extends Exception{ //传递参数>10时抛出并捕获异常 private int detail; public MyException(int a) { this.detail = a; } //toString:异 阅读全文
posted @ 2023-02-09 16:20 惊鸿宴远赴人间 阅读(10) 评论(0) 推荐(0)
摘要: public class Text { public static void main(String[] args) { int a=1; int b=0; //假设要捕获多个异常:从小到大(Throwable>Exception,Error) //Ctrl+Alt+T 快捷键 try{//try 阅读全文
posted @ 2023-02-09 15:52 惊鸿宴远赴人间 阅读(18) 评论(0) 推荐(0)