易错

每次comparator都不记得写object的leixing

 Arrays.sort ( intervals, new Comparator<Interval> (){
            public int compare ( Interval in1, Interval in2 ){
                return in1.start - in2.start;
            }
        });



HashMap 

void clear()
Removes all of the mappings from this map.
Object clone()
Returns a shallow copy of this  HashMap instance: the keys and values themselves are not cloned.
boolean containsKey(Object key)
Returns  true if this map contains a mapping for the specified key.
boolean containsValue(Object value)
Returns  true if this map maps one or more keys to the specified value.
Set<Map.Entry<K,V>> entrySet()
Returns a  Set view of the mappings contained in this map.
V get(Object key)
Returns the value to which the specified key is mapped, or  null if this map contains no mapping for the key.
boolean isEmpty()
Returns  true if this map contains no key-value mappings.
Set<K> keySet()
Returns a  Set view of the keys contained in this map.
V put(K key, V value)
Associates the specified value with the specified key in this map.
void putAll(Map<? extends K,? extends V> m)
Copies all of the mappings from the specified map to this map.
V remove(Object key)
Removes the mapping for the specified key from this map if present.
int size()
Returns the number of key-value mappings in this map.
Collection<V> values()
Returns a  Collection view of the values contained in this map.

JavaScript 编程中的易错点包括以下方面: 1. **基础概念易错点**: - **变量声明提升**:JavaScript 中变量声明会被提升到当前作用域的顶部,但赋值不会。这意味着在变量声明之前访问变量,不会报错,但值为 `undefined`。 - **数据类型转换**:JavaScript 是弱类型语言,在进行运算或比较时会自动进行数据类型转换,这可能导致意外的结果。例如,`'5' + 1` 结果是 `'51'`,而不是 `6`。 - **this 关键字的指向**:`this` 的指向在不同的情况下有所不同,它取决于函数的调用方式。例如,在全局作用域中,`this` 指向全局对象(在浏览器中是 `window` 对象);在函数内部,`this` 的指向取决于函数的调用方式,可能是全局对象、函数本身、构造函数实例等。 2. **作用域易错点**: - **程序块作用域**:在每个代码块中 JavaScript 不会创建一个新的作用域,一般各个代码块的作用域都是全局的。例如,以下代码的变量 `i` 返回 10,而不是 `undefined`: ```javascript for (var i = 0; i < 10; i++) { // some code } return i; ``` 3. **闭包易错点**: - **闭包中的循环变量**:在闭包中使用循环变量时,可能会出现意外的结果。因为闭包会捕获变量的引用,而不是变量的值。当循环结束后,变量的值已经发生了改变,导致闭包中使用的变量都是循环结束后的最终值。 4. **异步操作易错点**: - **异步操作的处理**:JavaScript 中的异步操作(如 `setTimeout`、`Promise`、`async/await` 等)如果处理不当,会导致代码执行顺序不符合预期。例如,在 `setTimeout` 中的回调函数会在主线程执行完后才执行。 5. **对象赋值易错点**: - **对象引用问题**:将一个对象赋值给另一个对象时,实际上传递的是对象的引用,而不是对象的副本。因此,修改新对象的属性会影响原对象。例如,将 `obj` 对象赋值给 `newObj` 对象,改变 `newObj` 的属性,`obj` 对象的属性也会被篡改,因为 `newObj` 获得的只是一个内存地址,而不是真正的拷贝 [^4]。 6. **DOM 操作易错点**: - **DOM 元素样式设置**:在设置 DOM 元素的样式时,如果赋值不当可能无法达到预期效果。例如,需要正确地给 `style.display` 属性赋值字符串 `"none"` 来隐藏元素 [^3]。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值