Clark To Do The blog of Clark

10个Java开发人员易犯的错误(译)

下面总结了10个Java程序员最易犯的错误.

1.Array与ArrayList转换

将一个数组array转换为ArrayList,程序猿通常这样做:

List<String> list = Arrays.asList(arr);

JavaScript typeof操作符

Javascript是一门弱类型语言,它拥有动态类型的特性,也就是说同一个变量可以作为不同的类型被应用到代码中.

typeof操作符作为一个全局的function, 可以被用作查询变量的类型.

JVM Statistics Monitoring Tool - jstat(To be continued)

jstat用于展现HostsSpot虚拟机器的性能统计信息(包括类加载,编译,堆内存等).

语法: jstat [ generalOption outputOptions vmid [interval[s ms] [count]] ]

How to handle right click in AngularJS

AngularJS中处理鼠标右键点击事件可以通过contextmenu实现,废话不多说,直接上代码:

1.HTML

<style type="text/css">
.action {
    cursor: pointer;
    border: 1px solid black;
    padding: 5px;
}
</style>
<div ng-app="myApp" ng-controller="MyCtrl">
    Right click me:
    <span class="action"
          ng-click="increment()"
          ng-right-click="decrement()"></span>
</div>

Install jekyll on windows

本站通过jekyll来生成静态页面,jekyll是Ruby语音编写的,因此在windows系统上的安装于配置较Linux来说,相对繁琐一些,本人安装过程的步骤如下:

1.通过rubyinstaller安装ruby。

How to Check if an Array Contains a Value in Java Efficiently?

How to check if an array (unsorted) contains a certain value? This is a very useful and frequently used operation in Java. It is also a top voted question on Stack Overflow. As shown in top voted answers, checking if an array contains a certain value can be done in several different ways, but the time complexity could be very different. In the following I will show the time each method takes.

1. Four Different Ways to Check If an Array Contains a Value

1.Using List:

public static boolean useList(String[] arr, String targetValue) {
    return Arrays.asList(arr).contains(targetValue);
}

JavaScript对象模型-执行模型(转)

数据类型
基本数据类型
基本数据类型是JS语言最底层的实现。
简单数值类型: 有Undefined, Null, Boolean, Number和String。注意,描述中的英文单词在这里仅指数据类型的名称,并不特指JS的全局对象N an, Boolean, Number, String等,它们在概念上的区别是比较大的。