"Java test" 修訂間的差異

出自 NCUCCWiki
前往: 導覽搜尋
(新頁面: {{Infobox java project | name = Java Logger | logo = | paradigm = reflective, [[Object-oriented progra...)
 
 
行 78: 行 78:
 
This is a minimal [[Hello world program]] in Java with [[syntax highlighting]]:
 
This is a minimal [[Hello world program]] in Java with [[syntax highlighting]]:
  
<source lang="java"><br>
+
<source lang="java">
// Hello.java<br>
+
// Hello.java
 
public class Hello {
 
public class Hello {
 
     public static void main(String[] args) {
 
     public static void main(String[] args) {
 
         System.out.println("Hello, world!");
 
         System.out.println("Hello, world!");
 
     }
 
     }
}<br>
+
}
 
</source>
 
</source>
  
 
[[Category:Java]]
 
[[Category:Java]]

於 2008年5月16日 (五) 03:12 的最新修訂

模板:Infobox java project

Java Logger

Lava Logger offers ten standard logging levels; from highest (coarsest) to lowest (finest):

  • EMERGENCY
  • ALERT
  • CRITICAL
  • FATAL
  • ERROR
  • WARNING
  • NOTICE
  • INFO
  • DEBUG
  • TRACE

History

unknow


package ncu.cc.log;

public class Example {
	
	private Logger	logger;

	public Example () {
		logger = Logger.getLogger(this.getClass().getName());
		logger.setLevel(Logger.LOG_DEBUG);
	}
	
	public void doSomething() throws Exception {
		logger.error("%d Hello", 1234);
		
		int	list[] = new int[1];
		
		try {
			list[5] = 10;
		} catch (Exception e) {
			logger.fatal(e);
			throw e;
		}
	}
	
	public static void main(String[] args) {
		Example ex = new Example ();
		Logger logger = Logger.getLogger();
		
		try {
			ex.doSomething();
		} catch (Exception e) {
			logger.fatal(e);
		}
			
		try {
			int x = 0;
			x = 5 / x;
			System.out.println (x);
		} catch (Exception e) {
			logger.error(e);
		}	
	}
}

This is a minimal Hello world program in Java with syntax highlighting:

// Hello.java
public class Hello {
    public static void main(String[] args) {
        System.out.println("Hello, world!");
    }
}