6月6日 日记

11:42pm
总结,今天第一次采取滚动日记的方式,就在不同时间点更新部落格,即时发送消息,效果看来不错。

11:26pm
刚发现一个有趣的 iPhone apps, BabbleOn,可以 post Facebook Voice Status 的。

11:17pm
要睡觉了,大家晚安。
感想:
点击聆听

11:13pm
技术问题,很奇怪,暂时显示不出 Flash 文件,在 Discuz X2 的漂浮框里。。。因此我暂时放了“点击这里直接进入游戏”的标题。

10:48pm
正在修复论坛升级后Flash游戏漂浮框显示的 Bugs。。。

9:04pm
很久没去清心国度论坛了,很少人在打理,啊!!!毕竟这论坛开了5年多,我还是会继续开下去,继续开100年。至少这个平台还是可以让我和我的家人联络,上面也可以玩 Flash Game,我妈妈有时会去玩(她电脑不会用,也只会玩上面的 Tetris,妹妹开给她。)。我还没想过做大。但,我需要找志同道合的人来当版主,一同打理。

8:58pm
刚发现 fyhao.com 发 youtube 的时候输入中文的话,无法正常显示,原来是 Imgshow Client API 没设置语言编码,已设置好了,下面的视频也能正常显示了。
真方便,发 youtube 歌曲只需直接输入歌名。。。

8:17pm
听着<当冬夜渐暖>。

我渐渐有希望了!

7:39pm
还是放工后比较轻松自在没压力。

6:32pm
最好是维持现状,因风水已定。。。
回家了,程序明天继续测试。

4:22pm
有感危机,希望能度过。

3:20pm
换房间?最好,千万别换好。

1:45pm
拜托给我大大大太阳,今天异常冷。

12:16pm
今天早上,公司来了两位新人。其中一位是实习生。
很紧张的感觉,因看到她的身影。

8:30am
今天苹果发布会哦,后天IPV6开始运行。


Labeled break in Java

According to Java Tutorials, the Break Statement, break used in Java has two forms: labeled break and unlabeled break.

Unlabeled break

Normally, we knew unlabeled break used in switch-case statement, to break the following execution in the block.

Example:

int HOUR = 3;
switch(HOUR) {
case 1:
case 2:
case 3:
break;
case 4:
break;
default:
break;
}

Or used in for, while, do-while loop, for example:

for(int i=0; i<10; i++) {
System.out.print(i + " ");
if(i == 3) break;
}

(Which printed: [1 2 3 ])

Labeled break

There is another type of break called labeled break. Besides to use goto statement in Java (you know goto is reserved keyword in Java but it is not supported), we can use labeled break to break the following execution and transfer the flow of control back to the labeled statement immediately.

Example:

int input = 3;
validation: {
System.out.println("start");
if(input == 4) System.out.println("pass");
if(input < 4) break validation;
System.out.println("the input is not equal 4 and not smaller than 4");
if(input > 4) break validation;
System.out.println(“end”);

}
System.out.println("another end");

It should print:
start
another end

The program execution will break from the validation block (declared curly braces) and jump to the end followed by the block.

Another example, if you have a nested loop, and you want to break and returns to the outer loop, you can:


cat: {
for(int i=0; i<3; i++) {
for(int j=0; j<5; j++) {
System.out.println(i + " - " + j);
if(j == 3) break cat;
}
}
}

It should print:
0 – 0
0 – 1
0 – 2
0 – 3

In the example 4, the cat block has curly braces surrounds the inner nested-for loop code. But if, we make something like this:


cat:
for(int i=0; i<3; i++) {
for(int j=0; j<5; j++) {
System.out.println(i + " - " + j);
if(j == 3) break cat;
}
}

In the example 5, the statement followed by label cat is now the nested for-loop without curly brace. Now we said label cat is just for the nested for-loop, if you break or continue in the inner for-loop, it will return the outer for-loop.

The result will be the same as Example 4, but if we change the break into continue, (continue will be valid in this example, but invalid in previous example), it turned into magic, see:


cat:
for(int i=0; i<3; i++) {
for(int j=0; j<5; j++) {
System.out.println(i + " - " + j);
if(j == 3) continue cat;
}
}

The result will be:
0 – 0
0 – 1
0 – 2
0 – 3
1 – 0
1 – 1
1 – 2
1 – 3
2 – 0
2 – 1
2 – 2
2 – 3

Argument

But, this kind of feature is rarely found in most program code. Programmer who worked 16 years experience told us this.

Labeled break provides similar or equivalent feature just like goto do. The goto is considered evil to the program because it makes the code unreadable. That’s why Java is not supported it. But I think there is another reason. But you may see labeled break do just goto do, then why Java supports labeled break but not supports goto. So, there is a reason, they are still different semantically.

Consider:

x : {
int a = 5;
if(a == 3) break x;
if(a == 5) break y;
}

y: {
int b = 3;
if(b == 3) break y;
if(b == 5) break x;
}

In the first X block, if a equal to 5, it will not jump break for Y block, and compiler will also prompt error. Labeled break is not able to break forward, but backward only. That’s mean, if you are inside X block, you only can break from X block or said current block, but not another block. This is the difference between labeled break and goto.

It just provides another flexibility to Java programmer, make code easier in some cases when there is a need to jump out from nested loop, I think this is the most use cases can use labeled break.

Additionally, repeated labeled block with same name is valid. Example:

test : break test;
test : { break test;}
test : {
System.out.print("test");
break test;
}

It prints “test”.

Last

I think it is valuable knowledge to share with you. Wish happy coding in Java.

Related Links:

  1. http://www.java2s.com/Code/Java/Language-Basics/BreakWithLabelDemo.htm
  2. http://www.java2s.com/Code/Java/Language-Basics/Labelledbreaksbreaksoutofseverallevelsofnestedloopsinsideapairofcurlybraces.htm
  3. http://stackoverflow.com/questions/5099628/why-does-java-allow-for-labeled-breaks-on-arbitrary-statements
  4. http://stackoverflow.com/questions/4546925/is-goto-as-bad-as-people-say

Existence of God?

Today Second Life ELF school we had a voice class, reading a comprehension of an article, and had a discussion around this. The topic we touched today is: Doomsdayers show what’s wrong with all religion. In this post, I will briefly tell you what we had discussed in the class, and besides that I will tell you what my belief is.

In the start of the class, we are told that we are not fighting with religion, we just to understand what the author wants to express. The author said religion is scam, but not really everything is a scam. Why the author said like this? The argument is that there is some of the religious people or priest always tell lie, such as the most people concerned – immortality. Or if we doing a good deed, we can going to heaven, otherwise going to hell. But we should say, this is a happy lie. Because of this, the followers are trying to do good deed, help poor people, giving helping hands to needed people. But there is some dishonest people telling people to give them money to save them from the end of the world. After May 21st, many people realized the religious statement wrong again.

Will you listen to what priest or religous people say and do what they say?

Above is all the statements we touched for today, I think it is not enough to claim the topic, but is it the religion is a scam? We should judge ourselves rationally.

My Thought

For me, as a free thinker, I do believe the existence of God, but I do not believe any religions at all. But I had tried to study all kinds of religions, either from Internet or books, to find their similarity, understand their core principle, in order to make my own principle, own judgement, to my own understanding, what is good and what is wrong, what should do and what should not do, in my life.

Many times, I don’t know, I practice scientific thinking, only something that is proved scientifically OR I really see it or feel it then I can define what the thing is true, otherwise it is false. I judge first, but not directly listen what the people say then I follow. I even said I not believing in ghost, vampire, monster, or god long times ago, but I am still not believing it, except God.

Now, you may ask me, to prove the existence of God, but I am not going to tell you, as there is no reasons why I should judge if God is exist or not. I believe God exist, He exist; otherwise not exist. God is staying in our heart, or anywhere.

God is not a substance, is not a person that you can see, is just special form created from our heart, because we need them, we need something or “someone” to listen to you, to comport you, or pray for safety.

Before year 2009, I am nothing, after the year 2009, I started to believe the God. Maybe I had done many bad things in my life last time (hacking is one of it), therefore I regretted, to repent, I followed the God, comprehended the truth, and behave what the truth stated.

To prove if the god is exist, I even can feel it by experiences. I believe if I do good thing, I may get good returns, but if I do something bad, I sure get bad luck. No matter how, if I do good thing, I felt happy, that’s good also, that’s why I follow God, and it is also a chance for me to atone.

Now, I felt well and gained confidence when I do everything in the name of God.

I pray for safety in the name of God. The safety of my family, my lover, followed by my relatives and friends, and then last, pets, is very important and must be protected, in the name of God. Safety for them is very important. Safety is the first.

I used to “contact” the God by my heart anytime, or swear an oath in the name of God with three fingers lifted up. I will not feel bad when I connected with the God.

But I am not perfect, everyone is not perfect, sometimes I did things carelessly, not in the name of God, made a lot of mistakes. But it is common. Learnt from experiences.

Last, now, “Is God exist?” will not be a question anymore.

In the name of God, I wrote this post.

Advice: don’t believe anything I wrote above, it can be rubbish, just letting you know my thoughts and you should digest and interpret by your own way.

程序里的哲学

我对我经手过的程序,虽然他们不是最好,达不到标准,有很大的进步空间,但我还是乐于重复阅读甚至分享,因为我觉得他们不是废物。虽然这些程序只占所有程序的1%。

每个程序都有灵魂,灵性。看一篇文章的写法构造。。。你可以了解作者的为人。若让我看一个人写的程序也能做同样的了解和分析。当然我所指的是高级语言,而不是低级语言。

如果你有一杯水你可以自己拥有,如果你有一桶水,你可以收在家里,如果你有一条河,你应当分享给大家。分享是一种美德,其他人感到快乐,你也会感到快乐。这是其中一个原因从事开源者持续支持开源的动力。

5月28日 记事

今天,和两个妹妹到city square逛街。原本想来看pirate的,哪知早一点的票卖完了,接下来的都很迟,所以我们就去其他地方。

我们去打game,玩了两场赛车,都很烂,过后就参她们女生玩图片找不同点的游戏,就比较厉害点。

很快的我们就去 Popular Bookstore,花了比较久的时间。我买了三本书:i) 第一本,有关如何建立及开展人际关系的。。。ii) 第二本,关于人生哲学的。。。iii) 第三本,维基解密阿桑奇的解密王国。

今天我也开始研究 Discuz X2 了,在本机里安装测试,升级了本机的论坛,过程顺利。测试了几个我编写的 Discuz X1.5 的插件,基本上不经修改,大部分功能都能使用。我测试了 Imgshow 平台,美食地点分享,和 Youtube 视频分享插件。我打算近期内专注开发升级 Imgshow 平台,支持这个 X2 新版。这次不只会修改 Bugs,也会改进使用功能。虽然东西很简单,但是还是有挑战性。另外,我打算把 DiscuzX2 系列主要在新马两地推广,支持英文版及马来文版翻译的工作(精神上支持),我也会继续免费发布英文和中文的 Discuz 插件。

Discuz X2 基本上做出了许多改进。最让我想要的功能则是手机访问。之前我特别写了 Jquery Mobile 版的,但是写得太简单,不大好。至于其他功能改进,大多都做得比较好,但有些功能比较多余,我就会忽略。基本上,Discuz 这个平台的开发质量还是好的,毕竟只是在中国,80% 的论坛都是用 Discuz 的。最近他们也发布云平台了,观望中。

相关链接:
1. Discuz X2 下载地址: http://www.discuz.net/thread-2166762-1-1.html