day11_0506
选择题
1.ArrayList是实现了基于动态数组的数据结构,LinkedList基于链表的数据结构。
ArrayList是基于数组实现的,所以查询快,增删慢;LinkedList是基于链表实现的,所以查找慢,增删快。
- key:是要保存到 Map 集合中的键名。
- value:是要保存到 Map 集合中对应键名的键值对象。
这种是默认创建大小为10的数组,每次扩容大小为1.5倍
ArrayList list=new ArrayList(20);
使用的ArrayList的有参构造函数,直接扩容,所以为零次
PreparedStatement从Statement继承而来
CallableStatement从PreparedStatement继承而来
Statement是爷爷,PreparedStatement是爸爸, CallableStatement是孙子
编程
最近公共祖先
public class LCA { public static void main(String[] args) { System.out.println(getLCA(2,3)); } public static int getLCA(int a, int b) { while(a!=b){ if(a<b){ b=b/2; }else { a=a/2; } } return a; } }求最大连续bit数
public class BitCount { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); System.out.println(Bit(n)); } private static int Bit(int n) { String str=Integer.toBinaryString(n); char[] c=str.toCharArray(); int count=0; int max=0; for (int i = 0; i < c.length; i++) { if (c[i]=='1'){ count++; }else { max=Math.max(max,count); count=0; } } max=Math.max(count,max); return max; } }







971

被折叠的 条评论
为什么被折叠?



