Java Programming
Time: 0900 ~ 1200, Saturday and Sunday
Location: Room 219, 德田館
``Java is C++ without the guns, knives, and clubs.''
-- James Gosling, co-inventor of Java (1955-)
Course Description
To the students,
This course is designed for the students who want to learn Java programming without any experiences before. We will start with the very beginning of program design and the fundamental concepts of how the programs execute the instructions. You are expected to be capable to implement your idea with Java independently after 30 hours of lectures. Furthermore, I wish you could learn other programming languages without suffering from starting over.
Enjoy your coding time.
- Textbook
- References
- Java (basic level)
- Barron's AP Computer Science A, Roselyn Teukolsky M.S., 7/e, 2015
- Beginning Java 8 Fundamentals, Kishori Sharan, 2014
- Introduction to Java Programming: Comprehensive Version, Y. Daniel Liang, 10/e, 2014
- Fundamental Object Oriented Programming, Prof. HT Lin, Dept of Computer Science and Information Engineering, National Taiwan Univerisity, Taiwan, 2015fa
- Introduction to Programming in Java, Robert Sedgewick and Kevin Wayne, Dept of Computer Science, Princeton University
- Programming notes, Chua Hock Chuan, Nanyang Technological University, Singapore
- Java (advanced level)
- Java Platform, Standard Edition (Java SE) 8, Oracle
- Java in a Nutshell, Benjamin J Evans and David Flanagan, 6/e, 2014
- Java: The Complete Reference, Herbert Schild, 9/e, 2014
- Effective Java, Joshua Bloch, 2/e, 2008
- Java Performance: The Definitive Guide, Scott Oaks, 2014
- OCP: Oracle Certified Professional Java SE 8 Programmer II Study Guide: Exam 1Z0-809, Jeanne Boyarsky and Scott Selikoff, 2016
- Data structures and algorithms
- Data Structures and Algorithms in Java, Michael T. Goodrich, Roberto Tamassia, and Michael H. Goldwasser, 6/e, 2014
- Data Structures and Problem Solving Using Java, Mark Allen Weiss, 4/e, 2010
- Data Structures and Algorithm Analysis, Clifford A. Shaffer, 2013 (online resource)
- Data Structure Visualizations, David Galles, Dept. of Computer Science, University Of San Francisco, 2011 (online resource)
- Object-oriented analysis and design (OOAD)
- Object-oriented Analysis and Design with Applications, Grady Booch, Robert A. Maksimchuk, Michael W. Engle, Bobbi J. Young, Jim Conallen, and Kelli A. Houston, 3/e, 2007
- Object-Oriented Analysis & Design, Prof. Kenneth M. Anderson, Department of Computer Science, University of Colorado, 2012fa
- Network programming
- Additional readings
- 為什麼要學各種程式語言, NiwaSho Lin, 2012.11.21
- 資深開發者給後輩的七個 Coding 學習心得, TechOrange, 2013.11.29
- 大企業都在用哪些程式語言?圖解程式語言編年史, T客邦, 2013.12.16
- 關於工程師 59 條搞笑但卻真實無比的語錄, INSIDE, 2013.12.20
- The reason everyone should learn to code, Mike Loukides, 2014.1.22
- 如何成為一個偉大的開發者?, TechOrange, 2014.6.20
- 沒神奇公式和捷徑,這11步驟就是成為頂尖Coder的必備條件, TechOrange, 2014.7.9
- 高生產力工程師的兩個特徵:聰明、懶惰, INSIDE, 2014.7.14
- 笑傲「演算法」江湖的獨孤九劍, INSIDE, 2014.8.14
- Google工程師親授:菜鳥開發者一定要投資的十大標的, TechOrange, 2014.9.17
- Re: [討論] 所以練acm都底有啥好處?, coquelicot, ptt, 2014.9.23
- 在美國,寫什麼程式收入最高?答案是:Java, T客邦, 2014.10.9
- 我們之前說錯了嗎?Coding 竟不是新世代必備能力, TechOrange, 2015.2.6
- 學 Coding 很簡單,但想要靠它吃飯你必須經過這4大階段, TechOrange, 2015.4.7
- 你自己選吧:當工程師不需數學好,但神級工程師的數學都很好, TechOrange, 2015.5.4
- code 海無涯,不想溺斃就快抓緊這 6 個緊急救生圈吧!, TechOrange, 2015.5.26
- 程式初學者的失落之鑰 - ``Computational Thinking'', 程式教育的唐吉訶德, 2015.6.2 (Original: Computational thinking and thinking about computing, Jeannette M Wing, 2008.10.28)
- 一個平庸工程師的自白, TechOrange, 2015.6.12
- 24 小時學會 Java 程式?想成為武林高手,還是先花 10 年磨一劍吧!, TechOrange, 2015.8.19
- 【洪士灝 v.s 蘇文鈺】真正的資訊教育不在學寫程式,關鍵在學用電腦解決問題, TechOrange, 2016.1.4
- AlphaGo: using machine learning to master the ancient game of Go, Google, 2016.1.27
- 人工智慧有多恐怖?聽聽「天才」Demis Hassabis 怎麼說!, INSIDE, 2016.2.21
- 葉丙成:學程式者,能成麒麟之才?, 翻轉教育, 2016.2.26
- Misc
- 高中生程式解題系統 (An Online Judge System For Beginners)
- Organization of Programming Languages, Michael Hicks and Anwar Mamat, Dept. of Computer Science, University of Maryland, 2015sp
- Introduction to Artificial Intelligence -- Pacman Project, Dept. of Computer Science, UC Berkeley, 2014sp
- LeetCode Online Judge
- openjdk/8u40-b25, GrepCode
- 程式語言面試考題集錦, maoyang, 2016.2.21
- code.org
- 2016 Introduction to Data Structure, Prof. Wing-Kai Hon, Department of Computer Science, National Tsing Hua University, 2016sp
- CMU 15-112: Fundamentals of Programming and Computer Science, Computer Science Department, Carnegie Mellon University, 2016sp
- w3schools.com
The major topics covered in the short course, time permitting, are listed below for your reference.
- Programming basics (procedural programming)
- Overview: preliminary knowledge of computer science, installation of Eclipse
- Data types and declaration
- Operators
- Control structures: selections, iterations
- Analysis of algorithms (O-notation)
- Methods (functions) and recursion
- Object-oriented programming
- Classes and objects
- Association, aggregation and composition: ``has-a'' relationship
- Inheritance and polymorphism: ``is-a'' relationship, upcasting, downcasting
- Interfaces: another ``is-a'' relationship
- Exception handling
- Generics
Note that I will introduce some of topics in Object-Oriented Analysis and Design (OOAD) with a tutorial of Unified Modeling Language (UML 2.0).
- Applications
- String and regular expressions
- File input and output
- Multi-threaded programming
- GUI design using Swing
- Fundamentals of network programming
- Applets, servlets, and JSP
These topics will be covered if we does continuously run ahead of schedule. For your information, we did reach and finish, based on the experience in the previous classes, the lecture for multitheading.
- 2016.1.9 (2.5 hours)
- 2016.1.10
- 2016.1.16 no class (Election day)
- 2016.1.17: selections and loops (3.5 hours)
- Problem 1: Greatest common divisor. Let a > b be any two positive integers. Write a program which determines the greatest common divisor of a and b by using Euclidean Algorithm.
- Problem 2: π estimated by Monte Carlo. Let n be the number of simulation paths. The algorithm is as follows:
- Set n = 1e5.
- Declare m = 0 and i = 0.
- Use Math.random() to generate x and y
- If x ^ 2 + y ^ 2 < 1, then m = m + 1.
- Set i = i + 1.
- Repeat (3) until i > n.
- Print 4 * m / n.
If you are not familiar with Monte Carlo simulation, you can refer to Calculating π using Monte Carlo Simulation.
- 2016.1.23: methods
- 2016.1.24: recursion, arrays
- Problem 3: Bisection method for root-finding. Write a program which determines the root of f(x) = x^3 - x - 2 by using Bisection Algorithm. If you are not familiar with this algorithm, please refer to How to Locate a Root :Bisection Method. (Hint: the root of f(x) = x^3 - x - 2 is around 1.52, so the algorithm needs the initial range covering the true root. For example, you can choose (0, 2) as the initial search range.)
- Problem 4: Number guessing game. Write a program which generates a secret number, randomly between 0 and 99, and receives the input from the player for his/her guess until the game is over. If the guess is equal to the secret number, then the program outputs ``Bingo.'' and the player wins. For the other hand, if the guess is higher/lower than the secret number, then the program outputs the updated range and waits for next input. For example, the program outputs (51, 99) after the player enters 50 for the first guess, assuming the secret number is 75. So the program continues to shorten the feasible range until the lower bound meets the upper bound. In this case, the program outputs ``Lose.'' and terminates.
- 2016.1.30 no class (Adjusted working day)
- 2016.1.31: class (part i)
- Problem 5: Matrix multiplication. Let A be an l-by-m and B be an m-by-n matrix. Then the product of A and B can be calculated by implementing a three-folded loop. Write a program which outputs the product of matrices. To test your program, you can generate the random integer matrix A and B as the input. If you are not familiar with matrix multiplication, please refer to here.
Read the page Stack and Queue (from CMU) or the slides of 13StacksAndQueues.pdf (from Princeton University).
- Problem 6: Stack. Implement a stack for integers. Recall that the important property of the stacks is first-in-last-out (FILO). You may use an array to store integers. You can follow the class diagram as follows.
You may implement a testing program for the integer stack. For example,
- Problem 7: Queue. Implement a queue for integers. Recall that the important property of the queues is first-in-first-out (FIFO). You may use an array to store integers. You can follow the class diagram as follows.
You may implement a testing program for the integer queue. For example,
- Problem 8: Depth-First Search (DFS) and Breadth-First Search (BFS) for the maze problem.
- First, download maze.zip for the main program with libraries. Second, build a new project with these 4 java files (in Eclipse or any IDE you used).
- A demo clip can be found here.
- As you can see, there are the red spots: one is the start point at the left bottom corner, the other is randomly located in the maze.
- Now, you can compile and run the maze with various sizes by setting the variable N in the main method of Maze.java.
- However, there is no agent who can reach the goal spot.
- Here, the agent is actually an algorithm for the maze.
- Your job is to implement the DFS and BFS algorithm as the agent.
- In the program, your agent is the method agent(int x, int y), which for now is not complete.
- You can find the visualized example for DFS and BFS.
- The detailed explanation for the search problem can be found here.
- It would be easier when you consider a stack in the DFS algorithm and a queue in the BFS algorithm.
- Note that this is a classical problem in Artificial Intelligence or related courses. If you have any technical problem, feel free to ask via email.
- 2016.2.6 no class (Chinese new year)
- 2016.2.7 no class (Chinese new year)
- 2016.2.13 no class (Chinese new year)
- 2016.2.14 no class (Chinese new year)
- 2016.2.20
- 2016.2.21
- Problem 9: Adapter class. Read pp. 340-342 of the slides. We will visit more examples of OOP in the last week. Those slides we need are available right now. In order to catch up the schedule, please refer to those slides before the class.
- 2016.2.27 no class (228)
- 2016.2.28 no class (228)
- 2016.3.5
- 2016.3.6, feedback
- Multitheading (Thanks to Mr. Sung)
- GUI design (part i) (Thanks to Mr. Sung)
- GUI design (part ii) (Thanks to Mr. Sung)
- Java with Web applications (Thanks to Mr. Sung)
- Problem 10 (Multithreading + Game design)
- Read the java source code: multithreadedGame.java
- Rewrite the tiny battle program using three threads for Arthur, Irene, and Tiger.
- You should take care of the synchronization problem and Producer-Consumer problem in the lecture notes CH.9.
- Alternatively, you can design your own battle program with new characters. It would be excellent.
- If you are not interested in this, please extend the Producer-Consumer Problem into Problem 7 in Java260.
- Problem 11 (Generics and Collection): Read java-generics.pdf.
- Problem 12 (Lambda expressions): Read Lambda Expressions.
Sample Codes
As a beginner, avoid copying. Please write the code on your own.
Grading Policy