- 博客(11)
- 收藏
- 关注
原创 Java——StringBuilder、StringBuffer
public class TestStringBuilder { public static void main(String[] args) { //StringBuilder 线程不安全,效率高,StringBuffer线程安全,效率低 StringBuilder sb = new StringBuilder("asdads"); //里面的内容可以随时修改, System.out.println(sb); System.out.println(Integer.toHexS
2020-05-27 00:18:23 135
原创 Java——Math
public class TestMath { public static void main(String[] args){ System.out.println(Math.ceil(3.2)); System.out.println(Math.floor(3.2)); System.out.println(Math.round(3.2)); System.out.println(Math.round(3.7)); System.out.println(Math.abs(-45));
2020-05-27 00:14:39 121
原创 Java——文件类的基本用法
public class TestFlile { public static void main(String[] args) throws IOException{ File f = new File("E:\\a.txt"); System.out.println(f); f.renameTo(new File("e:\\b.txt")); //改名 System.out.println(System.getProperty("user.dir")); //打印目录
2020-05-27 00:13:17 141
原创 Java——枚举
public class TestEnum { public static void main(String[] args) { System.out.println(Season.SPRING); Season a = Season.AUTUMN; switch(a){ case SPRING: System.out.println(); break; case SUMMER: System.out.println(); break; cas
2020-05-27 00:09:48 90
原创 Java——时间类的基本用法
public class TestDate { public static void main(String[] args) { Date d = new Date(); //什么都不传,则为当前的时刻 System.out.println(d); System.out.println(d.getTime()); //获取毫秒数 Date d1 = new Date(20000); //什么都不传,则为当前的时刻 System.out.println(d1); System.
2020-05-27 00:06:50 95
原创 Java——容器、ArrayList
public class TestList { public static void main(String[] args) { //test02(); test03(); } public static void test01() { Collection<String> c = new ArrayList(); //Set也有这些 System.out.println(c.size()); System.out.println(c.isEmpty());
2020-05-24 00:11:49 145
原创 Java——自定义异常
public class Test05 { public static void main(String[] args) { Person p = new Person(); p.setAge(-2); } } class Person{ private int age; public int getAge() { return age; } public void setAge(int age) { if(age<0) { throw new IllegelAg
2020-05-24 00:08:52 140
原创 Java——读取文本
public class Test02 { public static void main(String[] args) { //构建文件对象 FileReader reader = null;、 try { reader = new FileReader("d:\\a.txt"); char c1 = (char)reader.read(); System.out.println(c1); } catch (FileNotFoundExcepti
2020-05-24 00:06:19 75
原创 Java——数组的赋值方式
public class Test02 { public static void main(String[] args) { int[] a = {2, 3, 4}; //静态初始化 //数组可以保存对象 User[] b = { //静态初始化 new User(100, "xie"), new User(101, "ping"), new User(102, "yang") }; int[] c = new int[3]; //c的长度为3
2020-05-23 23:59:32 290
原创 Java——数组、、对象数组、增强for循环
public class Test01 { public static void main(String[] args) { int[] arr01 = new int[10]; String[] arr02 = new String[5]; //动态赋值 arr01[0] = 13; arr01[1] = 15; for(int i=0; i<10; i++) { //i<arr01.length arr01[i] = 10*i; }
2020-05-23 23:50:41 281
原创 Java——三目运算
public class Testoperator5 { public static void main(String[] args) { int score = 89; String type = score<60?"不及格":"及格"; System.out.println(type); } }片 问号后面是false时返回的结果 冒号后面是true时返回的结果
2020-05-23 23:45:41 180
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人