Java exception

异常(Exception),Ex前缀在中文大义就是排他、否定、外部,从字面上理解Exception就是和常态不一样的情况,也就是通常我们不希望出现的情况。人生之不如意,十之八九,比如吃烧饼烫后脑勺,交卷子的前一秒发现试卷有反面。

下面来谈谈Java中的程序异常和异常处理。程序也是生活的体现,99%的程序员都无法保证大型程序完全没有异常。所以,异常处理非常重要。对于异常的处理,可以将异常提示给程序员或者用户,让异常的程序以适当的方式继续进行或者终止,并让资源回滚。根据《Think in Java》Bruce写道的那样: “Java中的异常处理的目的在于通过少于目前数量的代码来简化大型、可靠的程序生成,并通过这种方式使你更自信:你的应用中没有你没有处理的错误。”

Duke趣事

美国人对大学貌似有一种归属感,感觉大学是美国人共同的精神家园。在杜克大学待了一年,我深深地被这所世界顶级名校的氛围所熏陶。理论上,在国内国外都有一大群人喜欢黑Duke的,按理说应该作为Duke学生就该低调。不过最近一朋友跟了一个Duke Fuqua商学院毕业的导师,她找我打听一下Duke的趣事,以便以后跟导师能有更多优质沟通的资本。然后我就觉得可以写点什么,让人了解一些这个Top7大学一些侧面。Actually, we are not just f*ing nerds。 这就是写这篇Blog的契机。


Outer Banks游记

Outer Banks是美国北卡州东面的一处海滩。中文翻译叫“外滩”,感觉怪怪的(LOL)。

该海滩虽然并不像马尔代夫那样的雪白的沙子,名气也不大,但是也有其让人惊艳的地方!我们学校离那里不过2小时车程,于是趁着Spring Break去玩了一下。

Crab

De...a bug

Debugging should be a kind of sports of mind, rather than the labor of coders’ body.

When I used Activiti with Spring frameworks this morning, the console firstly throws an error about ORM, which “friendly” indicates I missed a jar for “ibatis”.

Then, I added ibatis-2.3.0.677.jar and ibatis-common-2.jar to the user library, as well as the build path. However, eclipse cried again, like baby. The error information was ambiguous.

Even worse, I am still enjoying my vocation in China now. Due to gfw(Great Fire Wall), there is no easy way to use google in China. So I tried to find if there is any conflict about the different versions of jars. I tried to replace them with differrent versions. Thanks to Gad, this time the error information became much clear.

1
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/ibatis/type/TypeReference

So, there was no TypeReference class in ibatis. How? I tried 2-3 times by using other ibatis jars, and it still didn’t work!!!

Finally, I went crazy, and spent $10 to buy a VPN account to break the GFW to reach Google. Ohhhhh…The list of the ibatis jar showed it exactly did not have such a class. This was not a version issue.

Only mybatis has the TypeReference class. Therefore, I used mybatis-3.1.0.jar instead.

####Lesson: Don’t blindly try before carefully thinking about the reasons behind the desk. If the method is wrong, you just get a more step further when you try one more time.

Evaluate Reverse Polish Notation

###Question:
Evaluate the value of an arithmetic expression in Reverse Polish Notation.
Valid operators are +, -, *, /. Each operand may be an integer or another expression.

Some examples:

["2", "1", "+", "3", "*"] -> ((2 + 1) * 3) -> 9
  ["4", "13", "5", "/", "+"] -> (4 + (13 / 5)) -> 6

A simple example in jbpm

In some sense, JBPM is simple, because its goal is to offer process management features in a way that both business users and developers like it. Here I will give you a very simple JBPM example with Java action codeblock.

###JPDL
There is a JBoss jBPM Process Definition Language file, which defines the topology of the application process.

New Questions on Leetcode

There several new questions post on Leetcode. I picked 5 of them to practice yesterday. The solutions are pretty straightforward. Therefore, I just post my comments on after the code, instead of posting a long paragraph to explain.