1. int 数组的初始默认值是0
2. java HashMap
新建一个HashMap
HashMap <Integer, Integer> HashTable = new HashMap<>();
往里面放入值
HashTable.put(1,3);
获得key对应的value:
HashTable.get(1);
修改key对应的value:
HashTable.replace(key, new value);
得到HashTable中所有的值:
HashTable.values();
确定HashTable里面是否有这个键值:
HashTable.containsKey(1);
获取指定 key 对应对 value,如果找不到 key ,则返回设置的默认值:
HashTable.getOrDefault();
移除key以及对应的value
HashTable.remove();
遍历hashTable:
Set<Map.Entry<Integer,String>> sets= HashTable.entrySet();
for (Map.Entry<Integer, Integer> entry : sets){
int s = entry.getKey(), u = entry.getValue().
}
3. 字符串相关
访问某一索引的字符使用 .charAt
chatAt得到的字符用 == 跟 ''的元素进行比较
整个字符串的比较用equals()方法。
将字符串变为字符数组用toCharArray()方法。
字符串中字符或者子字符串的替换都可以用repalce();
4. StringBuilder类
append 往字符串最后添加元素。
insert(8,'Java')往字符串某-一位置插入元素。
delete(8,10)删除字符中的8-10位。
StringBuffer类可以用deleteCharAt删除某一位置的字符。
可以用toString()方法将其转变为字符串。
5. System类
将一个数组复制给另一个数组。
System.arraycopy(array,0,newarray,0,n);
第一个参数表示被复制的数组名称,第三个参数表示新数组,第二个参数是被复制的起始索引,第四个是复制数组的起始索引,第五个参数表示复制长度。