2者基本区别解析 java引用传递和值传递的区别( 四 )


1、新建状态(New):新创建了一个线程对象 。2、就绪状态(Runnable):线程对象创建后,其他线程调用了该对象的start()方法 。该状态的线程位于“可运行线程池”中,变得可运行,只等待获取CPU的使用权 。即在就绪状态的进程除CPU之外,其它的运行所需资源都已全部获得 。3、运行状态(Running):就绪状态的线程获取了CPU,执行程序代码 。4、阻塞状态(Blocked):阻塞状态是线程因为某种原因放弃CPU使用权,暂时停止运行 。直到线程进入就绪状态,才有机会转到运行状态 。http和https的区别?1、https协议需要到ca申请证书,一般免费证书较少,因而需要一定费用 。2、http是超文本传输协议,信息是明文传输,https则是具有安全性的ssl加密传输协议 。3、http和https使用的是完全不同的连接方式,用的端口也不一样,前者是80,后者是443 。4、http的连接很简单,是无状态的;HTTPS协议是由SSL+HTTP协议构建的可进行加密传输、身份认证的网络协议,比http协议安全 。常见的运行时异常?NullPointerException - 空指针引用异常ClassCastException - 类型强制转换异常 。IllegalArgumentException - 传递非法参数异常 。ArithmeticException - 算术运算异常ArrayStoreException - 向数组中存放与声明类型不兼容对象异常IndexOutOfBoundsException - 下标越界异常NegativeArraySizeException - 创建一个大小为负数的数组错误异常NumberFormatException - 数字格式异常SecurityException - 安全异常UnsupportedOperationException - 不支持的操作异常BIO和NIO区别?互联网 强调的是信息/数据在网络之间的流通,BIO:堵塞式IO,相当于轮船运输 NIO:非堵塞式IO:面向缓冲区(buffer),基于通道(chanel)的io操作,相当于火车运输,效率高文件->双向通道((缓冲区))->程序冒泡排序和自然排序及定制排序怎么实现的或者手写出来冒泡排序int[] arr={6,3,8,2,9,1};System.out.println("排序前数组为:");for(int num:arr){System.out.print(num+" ");}for(int i=0;i<arr.length-1;i++){//外层循环控制排序趟数for(int j=0;j<arr.length-1-i;j++){//内层循环控制每一趟排序多少次if(arr[j]>arr[j+1]){int temp=arr[j];arr[j]=arr[j+1];arr[j+1]=temp;}}}System.out.println();System.out.println("排序后的数组为:");for(int num:arr){System.out.print(num+" ");}自然排序1、定义一个类(文章中为Employee)实现Comparable接口2、重写Comparable接口中的compareTo()方法3、在compareTo()中按指定属性进行排序public class Employee implements Comparable{public int compareTo(Object o) {if (o instanceof Employee) {Employee e = (Employee) o;return this.name.compareTo(e.name);//按name进行排序}return 0;}} 定制排序1.创建一个Compartor实现类的对象,并传入到TreeSet的构造器中2.重写compare方法3.安照某个属性进行排序4.向集合中添加元素TreeSet set = new TreeSet(new Comparator() {@Overridepublic int compare(Object o1, Object o2) {if(o1 instanceof Student && o2 instanceof Student) {Student s1 = (Student)o1;Student s2 = (Student)o2;int s = s1.getAge() - s2.getAge();if(s == 0) {return s1.getName().compareTo(s2.getName());}return s;}return 0;}});set.add(new Student("aaa", 18));set.add(new Student("bbb", 8));set.add(new Student("fff", 38));set.add(new Student("ccc", 28));System.out.println(set); 在使用定制排序或是自然排序时,在其用到的类中都要重写hashCode()与equals()方法三种遍历方式?第一种遍历方法和输出结果 。
for(int i=1,i<list.size(),i++){System.out.println(list.get(i));}第二种用foreach循环 。加强型for循环 。推荐方式 。
for(String string:list){System.out.println(string);}第三钟迭代器
List<String> list=new ArrayList<>();list.add("abc");list.add("ghi");for(Iterator<String> it=list.iterator();it.hasNext();){System.out.println(it.next());}


以上关于本文的内容,仅作参考!温馨提示:如遇健康、疾病相关的问题,请您及时就医或请专业人士给予相关指导!

「四川龙网」www.sichuanlong.com小编还为您精选了以下内容,希望对您有所帮助: