⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 helloworld.java

📁 java核心编程的部分源码
💻 JAVA
字号:
 import java.lang.reflect.Method;
import java.lang.reflect.InvocationTargetException;

/**
* <code>main()</code> invokes "Hello world" reflectively.
**/

public class HelloWorld
{
public static void main( String[] args )
{
Class outClass = System.out.getClass();
Class[] argTypes = new Class[] { String.class };

try
{
Method printMethod = outClass.getMethod( "println", argTypes );
printMethod.invoke( System.out, new Object[] { "Hello World!" } );
}
catch ( NoSuchMethodException e )
{
System.err.println( "Can"t find method: " + e.getMessage() );
}
catch ( SecurityException e )
{
System.err.println( "Can"t find method: " + e.getMessage() );
}
catch ( IllegalAccessException e )
{
System.err.println( "Can"t invoke method: " + e.getMessage() );
}
catch ( IllegalArgumentException e )
{
System.err.println( "Can"t invoke method: " + e.getMessage() );
}
catch ( InvocationTargetException e )
{
System.err.println( "Can"t invoke method, threw: "
+ e.getTargetException().getMessage() );
}
}
} 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -