
Java基础
姜崽
这个作者很懒,什么都没留下…
展开
-
Java中cpu与程序之间的关系
尽量不要玩,电脑会死机,需要重启/** * 电脑死机 */public class TestCpu { public static void main(String[] args) throws InterruptedException { //线程是任务调度的最小单位,线程过多,会严重消耗cpu while(true){ Thread.sleep(4); new Thread(){原创 2020-10-10 19:38:18 · 280 阅读 · 0 评论 -
Java内存与程序之间的关系
这里是代码。看着比较直观public class TestMonery { //内存溢出// ArrayList<byte[]>list=new ArrayList<>(); //jvm有垃圾回收机制,入股堆中的内存没有引用指向,则被回收 public static void main(String[] args) { while (true){ byte[] bf = new byte[1024];原创 2020-10-10 19:34:38 · 238 阅读 · 0 评论 -
Java磁盘与程序之间的关系
主要发生在文件处理中,比如使用I/O流读写文件时。程序会影响到磁盘使用率。public class TestDisk { public static void main(String[] args) throws IOException { // 123.zip是源文件,d,是目标盘 copyFileByBuf("E:\\123.zip","D:"); } public static void copyFileByBuf(String srcPath,S原创 2020-10-10 19:29:48 · 143 阅读 · 0 评论 -
Java二分查找-高效率的查找
二分查找:效率高被查找的数组元素,必须是有序的 public static void main(String[] args) { int[] arr = {1,4,7,10,13,15,21,25}; int index = binarySearch(arr,12); System.out.println(index); index = binarySearch(arr,7); System.out.println(inde原创 2020-10-10 19:22:40 · 120 阅读 · 0 评论 -
Java快速排序案例
public class QuickSort { public static void quickSort(int[] arr,int low,int high){ int i,j,temp,t; if(low>=high){ return; } i=low; j=high; //temp就是基准位 temp = arr[low]; whi原创 2020-10-10 19:17:36 · 298 阅读 · 0 评论