Skip to content

Instantly share code, notes, and snippets.

@edwardyi
Last active February 12, 2019 07:04
Show Gist options
  • Save edwardyi/88d2772df5b85e208f42473e75d09a50 to your computer and use it in GitHub Desktop.
Save edwardyi/88d2772df5b85e208f42473e75d09a50 to your computer and use it in GitHub Desktop.

Revisions

  1. edwardyi revised this gist Feb 12, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -10,7 +10,7 @@ public class Test{
    System.out.println(arr[i]);
    }
    }
    public function main(String args[]){
    public static void main(String[] args){
    // 沒有指定型別的話會出現小黃線
    ArrayList<Integer> arr = new ArrayList<Integer>();
    arr.add(1);
  2. edwardyi created this gist Feb 12, 2019.
    25 changes: 25 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@

    // 沒有加會有小紅線提示
    import java.util.ArrayList;
    public class Test{
    public static void test1{
    int[] arr = new int[10];
    arr[0] = 2;
    arr[1] = 3;
    for(int i=0; i< arr.length; i++){
    System.out.println(arr[i]);
    }
    }
    public function main(String args[]){
    // 沒有指定型別的話會出現小黃線
    ArrayList<Integer> arr = new ArrayList<Integer>();
    arr.add(1);
    arr.add(3);
    arr.add(5);
    arr.remove(1); //移除第二個元素
    for(int i=0; i<arr.size(); i++){
    // 使用get來取得陣列的值
    System.out.println(arr.get(i));
    }
    }
    }