自从我开始学习java,看了<thinking in java>的前6章,发现那本书不适合没有java基础的人学习.我买了一本<java core:基础知识>在读,我发现那本书写的不错,也很适合我门这种菜鸟来读.读起来那本书就象在吃肉家膜. 我感觉学习java技术的捷径应该是从实践入手,看别人的原代码一定可以对学习的知识有到认识和提高的过程,一定可以加快自己学习的过程,所以我找了一个开源的软件下来看看他的原代码,我下的这个项目叫做J,是一个多文本的文本编辑器,适合程序员使用,因为他可以分析原代码的类,并列出表来.还可以语法高亮显示.其实感觉挺不错的.我看了他的原代码,写的不错,格式很好看,就是注释的太少了,我感觉是不是开源的软件代码应该对写点注释才会更好呀.下面我给出我今天看的那个Main.java的代码,其实没有几行的,不过感觉自己的收获不小呀!!! /* * Main.java * * Copyright (C) 1998-2003 Peter Graves * $Id: Main.java,v 1.3 2003/07/04 14:25:26 piso Exp $ * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
import java.lang.reflect.Method;
public final class Main { public static void main(String[] args) { final String version = System.getProperty("java.version"); if (version.startsWith("1.0") || version.startsWith("1.1") || version.startsWith("1.2") || version.startsWith("1.3")) { System.err.println(""); System.err.print("J requires Java 1.4 or later."); System.err.println(" (Java 1.4.2 is recommended.)"); System.err.println(""); System.exit(1); } try { Class c = Class.forName("org.armedbear.j.Editor"); Class[] parameterTypes = new Class[1]; parameterTypes[0] = String[].class; Method method = c.getMethod("main", parameterTypes); Object[] parameters = new Object[1]; parameters[0] = args; method.invoke(null, parameters); } catch (Exception e) { e.printStackTrace(); } } }

|