- 編輯器設定 soft tab (space=2),以 2 格空白符號做為程式內縮距離(不分語言)。
- 函式如果只有一個參數,就不強制打()
- 函式如果有二個以上的參數,通通都要有 ()
- (避免發生奇怪的paser bug跟保持專案一致性)
- 字串限定用雙引號包覆
- 善用 "#{str1} #{str3} " 等字串改寫技巧取代不需要的字串加法。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ThreeException extends Exception{} | |
public class FinallyWorks { | |
static int count =0; | |
public static void main(String[] args) { | |
while(true){ //如果把try放到循环里,就建立了一个”程序继续执行之前必须要达到“的条件,同时也可以加入一个静态计数器,使之能尝试一定的次数 | |
try{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package hoodoo.SimpleException; | |
/** | |
* Created by IntelliJ IDEA. | |
* User: Hoodoo | |
* Date: 11-4-9 | |
* Time: 上午11:35 | |
* To change this template use File | Settings | File Templates. | |
*/ | |
import static java.lang.System.*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package hoodoo.reflection.proxy; | |
import java.lang.reflect.InvocationHandler; | |
import java.lang.reflect.Method; | |
import java.lang.reflect.Proxy; | |
/** | |
* Created by IntelliJ IDEA. | |
* User: Hoodoo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package timer; | |
import java.io.IOException; | |
import java.util.Timer; | |
import java.util.TimerTask; | |
/** | |
* Created by IntelliJ IDEA. | |
* User: Hoodoo | |
* Date: 11-4-26 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
require 'rubygems' | |
require 'nokogiri' | |
require 'open-uri' | |
uris = File.open("c:\\url1.txt",'r') | |
#ratings = File.open("ratings.txt",'w') | |
i=0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test_dir = Dir.open("expert ratings") | |
test_dir.entries[2..-1].each do |f| | |
begin | |
file = File.open("E:\\ratings_all\\expert ratings\\"+f.to_s) | |
rescue Errno::ENOENT=> error | |
next | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test_dir = Dir.open("expert ratings") | |
test_dir.entries[2..-1].each do |f| | |
begin | |
file = File.open("E:\\ratings_all\\expert ratings\\"+f.to_s) | |
rescue Errno::ENOENT=> error | |
next | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Kitty | |
class << self | |
puts "#{self.inspect} -- #{self.object_id}" #a点 | |
def hello | |
puts "#{self.inspect} -- #{self.object_id}" #b点 | |
puts "#{Kitty.inspect} -- #{Kitty.object_id}" #c点 | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class App { public App(String name) { System.out.println(name + "'s constructor called"); } static { System.out.println("static initializer called"); } { System.out.println("instance initializer called"); } static { System.out.println("static initializer2 called"); } { System.out.println("instance initializer2 called"); } public static void main( String[] args ) { new App("one"); new App("two"); } } |
OlderNewer