This file contains hidden or 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 Base{ | |
public void foo() throws FileNotFoundException { | |
thorw new FileNotFoundException(); | |
} | |
} | |
class OverideTest extends Base{ | |
public void foo() throws IOException{ | |
throw new IOException(); | |
} |
This file contains hidden or 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
private static void runCase1() { | |
int j = 10; | |
Point point = new Point(4, 4); | |
logger.info(“Before Modify Point {}, j ={}”, point, j); | |
setPointLocation(point, j); | |
logger.info(“After Modify Point {}, j ={}”, point, j); | |
// Result | |
// Before Modify Point Point{y=4, x=4}, j =10 |
This file contains hidden or 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
private static void runCase2() { | |
int j = 10; | |
Point point = new Point(4, 4); | |
logger.info(“Before Modify Point {}, j ={}”, point, j); | |
setPointWithAssign(point, j); | |
logger.info(“After Modify Point {}, j ={}”, point, j); | |
// Result | |
// Before Modify Point Point{y=4, x=4}, j =10 |
This file contains hidden or 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 static void main (String args[]){ | |
ServerSocket serverSocket = new ServerSocket(199); | |
try{ | |
Socket socket = serverSocket.accept(); | |
} | |
finally{ | |
socket.close(); | |
} | |
} |
This file contains hidden or 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 void checkEmptyUserName(String username){ | |
if(StringUtils.isBlank(userName)){ | |
throws new LoginFailedException("Username is empty!"); | |
} | |
} |
This file contains hidden or 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 static class verfiyExceptionTest{ | |
@Rule | |
public ExpectedException thrown= ExpectedException.none(); | |
@Test | |
public void throwsExceptionWithMessage() { | |
// 預期 LoginFailed 會產生以及對應的 Exception message | |
thrown.expect(LoginFailedException.class); | |
thrown.expectMessage(startsWith("UserName")); |
This file contains hidden or 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 void demoException() throws Exception{ | |
try{ | |
throw new ("Exception A"); | |
} catch (Exception e){ | |
throw new Exception("Exception B"); | |
} finally { | |
throw new Exception("Exception C"); | |
} | |
} |
This file contains hidden or 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 void demoException() throws Exception{ | |
try{ | |
throw new ("Exception A"); | |
} catch (Exception e){ | |
throw new NestableException("Exception B", e); | |
} | |
} |
This file contains hidden or 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 Excperf { | |
public void method1(int size){ | |
int [] ia = new int[size]; | |
try{ | |
for (int i = 0;i<size ; i++){ | |
ia[i] = i; | |
} | |
} catch (Exception e){ | |
} |
This file contains hidden or 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 hello; | |
public class OCR { | |
public static void main(String[] args) | |
{ | |
String first = "ba6"; | |
String second = "1Ad"; | |
boolean res = Ocr(first, second); | |
System.out.println(countingWordsLength(first)); |