Skip to content

Instantly share code, notes, and snippets.

View BalicantaYao's full-sized avatar

Balicanta BalicantaYao

View GitHub Profile
@BalicantaYao
BalicantaYao / 0_reuse_code.js
Last active August 29, 2015 14:14
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@SpringBootApplication()
public class PublisherIntegrationPlatformApplication extends SpringBootServletInitializer {
private static final Logger log = LoggerFactory.getLogger(PublisherIntegrationPlatformApplication.class);
public static void main(String[] args) {
SpringApplication.run(PublisherIntegrationPlatformApplication.class, args);
}
@Override
@BalicantaYao
BalicantaYao / .java
Created April 21, 2017 14:10
a4.橫條圖
/* a4.(橫條圖,bar graph)
* (1) - 亂數產生10個整數,值介於0-50之間,存到一維陣列內,
* public ArrayList<Integer> createNumber(){
*
* }
*
* public void printStar(int num){
* // 20
* }
*
/*
* a3.(頻度統計,histogram) 亂數產生1000個介於1~10的整數,
* 請統計1~10各出現多少次.
*
* (1) 用 HashMap 的方式!
* (2) 用 Array 的方式!
*/
@BalicantaYao
BalicantaYao / DateExctract.java
Created April 25, 2017 14:42
日期取出、列印練習
/*
u1-1. (*) 寫三個方法取出年、月、日 , 2017/01/21
public int getYear(String date){
// 2017
}
public int getMonth(String date){
//1
@BalicantaYao
BalicantaYao / GradeBook.java
Created April 28, 2017 10:11
類別建立練習
/*
s1.(成績簿)
實作一成績簿類別GradeBook,內含私有科目名courseName,型別為字串,
對外提供如下公開方法:
public String getCourseName() // 讀出科目名
public void setCourseName(String name) // 寫入科目名
public void displayMessage() // 印"歡迎來到xx成績簿物件"訊息,xx為科目名
測試時,可建構一個成績簿物件,向用戶要一個科目名,
寫入成績簿物件,再讀出,並列印訊息.
*/
@BalicantaYao
BalicantaYao / AccountObject.java
Last active May 9, 2017 16:16
類別建立 - 戶頭
/*
s4.(戶頭)
實作一戶頭類別Account,內含私有餘額balance,型別實數,
對外提供如下公開方法:
public Account(double initialBalance) //建構子,含初始餘額
public void credit(double amount) // 存款,含存款金額
public double getBalance() // 讀出餘額,回傳餘額
測試時,可用建構子建立一個戶頭,初始餘額為50,先印餘額看對不對,
再存入25,印餘額看對不對.
@BalicantaYao
BalicantaYao / FileReadExample.java
Created May 5, 2017 14:14
讀取檔案內容範例
public class FolderRead {
public static void main(String[] args) throws IOException {
// files 路徑
File files1 = new File("files");
File[] files2 = files1.listFiles();
for (File file : files2) {
class Exception1 extends Exception{}
class Exception2 extends Exception1{}
class Exception3 extends Exception2{}
class Lazy{
public void foot(int i) throws Exception1 {
if(i == 1){
throw new Exception1();
} else if(i==2){
throw new Exception2();
} else if(i==3){
try{
Lazy sample = new Lazy();
l.foo(1);
} catch (Exception1 exec){
// Handle
// 在這裡你很難發現 Exception 是 Exception1 or Exception 2 or Exception3
}