multreturntypetrycatchfinallytest.java

来自「配置文件」· Java 代码 · 共 87 行

JAVA
87
字号
/**
 * Copyright (c) 2003-2004 Craig Setera
 * All Rights Reserved.
 * Licensed under the Eclipse Public License - v 1.0
 * For more information see http://www.eclipse.org/legal/epl-v10.html
 */
package preverification.inputs;

import preverification.tests.ITestable;
import preverification.tests.TestException;

/**
 * Type description
 * <p />
 * Copyright (c) 2003-2004 Craig Setera<br>
 * All Rights Reserved.<br>
 * Licensed under the Eclipse Public License - v 1.0<p/>
 * <br>
 * $Revision: 1.3 $
 * <br>
 * $Date: 2005/10/22 20:22:30 $
 * <br>
 * @author Craig Setera
 */
public class MultReturnTypeTryCatchFinallyTest implements ITestable {
	/**
	 * @see preverification.tests.ITestable#test(java.lang.Object[])
	 */
	public Object test(Object[] arguments) 
		throws TestException 
	{
		Object returnValue = null;
		
		try {
			returnValue = new Integer(testInt());
		} catch (Exception e) {
			returnValue = new Long(testLong());
		} finally {
			returnValue = new Object();
		}
		
		test2(5);
		
		return returnValue;
	}
	
	private void test2(int switchValue) {
		Object testValue = null;
		
		if (switchValue > 0) {
			testValue = new Object();
		} else {
			testValue = "Test String";
		}
		
		System.out.println(testValue);
	}
	
	private int testInt() {
		int value = 0;
		
		try {
			value = 1;
		} catch(Exception e) {
			value = 2;
		} finally {
			value = 3;
		}
		
		return value;
	}
	
	private long testLong() {
		long value = 0;
		
		try {
			value = 1;
		} catch(Exception e) {
			value = 2;
		} finally {
			value = 3;
		}
		
		return value;
	}
}

⌨️ 快捷键说明

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