Java第6堂: Data Structure & OOP again

Back
Category : Home

Stack例子:

import java.util.Stack;

public class Example6 {
	public static void main(String args[]) {
		Stack<String> s = new Stack();
		s.add("A");
		s.add("B");
		s.add("C");

		s.remove(1);
		System.out.println(s.size());

		System.out.println(s.pop());
		if (!s.empty()) {
			System.out.println(s.pop());
		}
		System.out.println(s.pop());
		if (!s.empty()) {
			System.out.println(s.pop());
		}
	}
}

Lee Cheuk Nam 李卓男

功課一 : 改下段Bubble Sort Code令到佢唔好Loop咁多次

功課二:將下面張圖轉成Code

功課一

功課二

練習

public class Example1{
	public static void main(String args[]){
		int score=55;

		if (score >= 80){
			System.out.println("A");
		}else if (score >= 60){
			System.out.println("B");
		}else if (score >= 40){
			System.out.println("C");
		}else{
			System.out.println("F");
		}

		System.out.println("End");
	}
}

PowerPoint

Notes

  1. 下載Java https://java.sun.com
  1. 以下是HelloWorld代碼
class Example1{
    public static void main(String args[]){
          System.out.println("Hello World");
    }
}

Compile指令

javac Example1.java
java Example1

常見錯誤

錯誤一 : 打錯字

首先打錯字唔洗驚, 睇下個Error Message, 佢會有個箭咀指住大約錯邊個位, 同埋有個行數, 跟住就可以揾到錯邊

錯誤二: Save錯文件名

錯誤張文件名Save做.java.txt, 所有Java文件必需要用.java做尾. 你地係notebook到要簡下面嘅撰項

Get in HKPS website, you see “Hour Of Code” menu on top

If you are not registered yet, you jump in above page. Two options: register for teen or adult

This is the main screen, since we don’t have many courses yet, so no search bar. “On going” means the course still has lessons, you may ask teacher questions. “Done” means the course is ended, no question to teacher.

View course info and video play back

Lunch with Thei and Microsoft to discuss the project about the AI platform

Chairman 2023-2025 of hong kong programming society is Peter Cheung Man Kit, he is the founder of quantr limited and CIO of Lions Clubs Hong Kong D303. He is a passionate guy who focus on coding.