随笔分类 - java
摘要:实例化对象的3种方式:new、clone、反射
阅读全文
摘要:1 package 反射; 2 interface Product{ 3 public void produce(); 4 } 5 class socks implements Product{ 6 @Override 7 public void produce() { 8 System.out.p
阅读全文
摘要:1 package 反射; 2 3 public class Test反射 { 4 public static void main(String[] args) { 5 System.out.println(Runtime.getRuntime().getClass());//class java.
阅读全文
摘要:1 package 正则; 2 3 import java.util.regex.Matcher; 4 import java.util.regex.Pattern; 5 6 public class Test_regex { 7 public static void main(String[] a
阅读全文
摘要:1 package 正则; 2 3 public class TestIsNum { 4 public static void main(String[] args) { 5 String s1="abc"; 6 String s2="98765234567800987654321123456789
阅读全文
摘要:1 package 对象比较排序; 2 3 import java.util.Arrays; 4 5 class A implements Comparable<A>{ 6 private String name; 7 private int age; 8 public A(String name,
阅读全文
摘要:1 package Arrays类; 2 3 import java.util.Arrays; 4 5 public class TestArrays { 6 public static void main(String[] args) { 7 int[] a={1,9,3,5,7,8,2,6,0,
阅读全文
摘要:1 package 日期日历类; 2 3 import java.text.ParseException; 4 import java.text.SimpleDateFormat; 5 import java.util.Date; 6 7 public class TestDate { 8 publ
阅读全文
摘要:1 public class TestDate { 2 public static void main(String[] args) { 3 System.out.println(new java.util.Date()); 4 } 5 } 运行结果:Fri Apr 07 21:56:24 CST
阅读全文
摘要:1 package 彩票中奖码生成器; 2 3 import java.util.Random; 4 5 public class TestRandom { 6 public static void main(String[] args) { 7 Random random=new Random()
阅读全文
摘要:1 package math; 2 3 public class TestMath_round { 4 public static void main(String[] args) { 5 System.out.println(Math.round(0.5));//1 6 System.out.pr
阅读全文
摘要:1 package 对象克隆; 2 class A implements Cloneable{//要具备clone()功能必须要实现Cloneable接口,此接口里无方法,只起标识作用。 3 private String value; 4 public A(String value){ 5 this
阅读全文
摘要:1 package 对象被回收前执行的操作; 2 class A{ 3 @Override 4 protected void finalize() throws Throwable { 5 System.out.println("在对象变成垃圾被gc收回前执行的操作。"); 6 } 7 } 8 pu
阅读全文
摘要:1 public class Test_currentTimeMillis { 2 public static void main(String[] args) { 3 long start=System.currentTimeMillis(); 4 for(int i=0;i<Integer.MA
阅读全文
摘要:1 package 多线程; 2 class Producer implements Runnable{ 3 private Data data; 4 public Producer(Data data){ 5 this.data=data; 6 } 7 @Override 8 public syn
阅读全文
摘要:1 package 多线程; 2 class A{ 3 public synchronized void say(B b){ 4 System.out.println("A说:你把你的本给我,我把我的笔给你!"); 5 b.get(); 6 } 7 public synchronized void
阅读全文
摘要:1 package com.tn.hashMap; 2 3 import java.util.HashMap; 4 import java.util.TreeSet; 5 6 public class HashMapDemo { 7 public static void main(String[]
阅读全文
摘要:1 package com.tn.hashMap; 2 3 public class Student { 4 private String id; 5 private String name; 6 public Student(String id, String name) { 7 super();
阅读全文
摘要:1 package com.tn.treeSet; 2 3 public class Student { 4 private String name; 5 private int age; 6 public Student(){} 7 public Student(String name, int
阅读全文
摘要:1 package com.tn.hashSet; 2 3 public class Person { 4 private int id; 5 private String name; 6 private String birthday; 7 public Person(int id, String
阅读全文

浙公网安备 33010602011771号