Java Programming
Time: 0900 ~ 1200, Saturday and Sunday
Location: Room 108, 德田館
``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
- Java: advanced
- 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
- Data structures and algorithms
- Object-oriented analysis and design (OOAD)
- Network programming
- Eclipse
- Additional readings
- Why Learn to Program?, Alex Allain
- 為什麼要學各種程式語言, NiwaSho Lin, 2012.11.21
- 資深開發者給後輩的七個 Coding 學習心得, TechOrange, 2013.11.29
- 大企業都在用哪些程式語言?圖解程式語言編年史, T客邦, 2013.12.16
- The reason everyone should learn to code, Mike Loukides, 2014.1.22
- 如何成為一個偉大的開發者?, TechOrange, 2014.6.20
- 前蘋果高層史丹佛畢典演講:想換工作,別在辦公室等著別人幫你下決定, TechOrange, 2014.7.7
- 沒神奇公式和捷徑,這11步驟就是成為頂尖Coder的必備條件, TechOrange, 2014.7.9
- 高生產力工程師的兩個特徵:聰明、懶惰, INSIDE, 2014.7.14
- 笑傲「演算法」江湖的獨孤九劍, INSIDE, 2014.8.14
- Google工程師親授:菜鳥開發者一定要投資的十大標的, TechOrange, 2014.9.17
- 在美國,寫什麼程式收入最高?答案是:Java, T客邦, 2014.10.9
- 我們之前說錯了嗎?Coding 竟不是新世代必備能力, TechOrange, 2015.2.6
- code 海無涯,不想溺斃就快抓緊這 6 個緊急救生圈吧!, TechOrange, 2015.5.26
- 程式初學者的失落之鑰 - “Computational Thinking”, 程式教育的唐吉訶德, 2015.6.2 (Original: Computational thinking and thinking about computing, Jeannette M Wing, 2008.10.28)
- 24 小時學會 Java 程式?想成為武林高手,還是先花 10 年磨一劍吧!, TechOrange, 2015.8.19
- Misc
The major topics covered in the short course, time permitting, are listed below for your reference.
- Overview: preliminary knowledge of computer science, installation of Eclipse
- Data types and identifiers
- Operators
- Control structures: selections, iterations
- Methods and recursions
- Classes and objects
- Program design and analysis of algorithms: UML, O-notation
- Object aggreagation and composition: ``has-a'' relationship
- Inheritance and polymorphism: ``is-a'' relationship, upcasting, downcasting
- Interfaces: another ``is-a'' relationship
- Generics
- String and RegExp
- Exception handling
- File input and output
- Multi-threaded programming
- GUI by Swing
- Fundamentals of network programming
- Applets, servlets, and JSP
- 2015.11.14 (2 hours)
- 2015.11.15
- 2015.11.21 (3.5 hours)
- 2015.11.22 (3.5 hours)
- Problem 1: Write a program which determines the root of f(x) = x^3 - x - 2 by using Bisection algorithm.
- Problem 2: Estimating pi value by Monte Carlo. Let n be the number of simulation paths. The algorithm is as follows:
- Declare m = 0 and i = 0.
- Use Math.random() to generate x and y with i = i + 1.
- If x ^ 2 + y ^ 2 < 1, then m = m + 1.
- Repeat (2) until i > n.
- Print 4 * m / n.
- Problem 3: 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 player wins. Otherwise, for the guess higher/lower than the secret number, the program outputs ``Too high.'' and ``Too low.'', respectively. If the player tries more than 10 times, then the player loses the game.
- 2015.11.28
- 2015.11.29
- Problem 4: Write two programs for the GCD (greatest common divisor) problem. Let a > b be any two positive integers. Find the greatest common divisor of a and b. Please implement one program by a loop and the other by a recursive function.
- Problem 5: Write a program which outputs the solution of Tower of Hanoi. You can refer to this Wikipedia page here for the detail or you can watch this video here.
- Problem 6: Write a program for 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-level loop. You can refer to the Wikipedia page here. The program outputs the product of matrices. To test your program, you can generate the random matrix A and B.
- Problem 7: Observer around. Define a new class for this world. The class should have at least two fields and two methods. (If you don't have any idea, then you may try to define the new class Triangle. For the Triangle class, write two methods for the perimeter and the area of the Triangle objects.) It is an open question. Would be no standard answer. Feel free to design your world.
- Sample codes (Thanks to Joe Chen)
- 2015.12.5
- 2015.12.6
- String and Regular Expressions (Thanks to Mr. Sung)
- Problem 8: Write a program which converts the input string by upper-casing the small letters (e.g. a) and lower-casing the big letters (e.g. A). For example, the input string is ``Abc''. So the output string is clearly ``aBC''.
- Problem 9 (caesarCiperTest.java): Write a program which implements Caesar Cipher. Define the Cipher class to encrypt your plain text and define the Decipher class to decrypt the cipher text. In addition, you may write another class Caesar to test your program by invoking the main method with your plain text. The program should output the plain text, its cipher text, and also decrypted text. For example,
- Problem 10 (Problem10.java): Stack is one of basic data structures. The stack can be logically thought as linear structure represented by a real physical stack or pile, a structure where insertion and deletion of items takes place at one end called top of the stack. Write a program which simulates a laundry basket where you can push the dirty clothes and take out of them to the washing machine as you wish.
- Define an abstract class Item with a field str.
- Define the Tshirt class and the Pants class. Both inherit Item and have a static integer field cnt. Both constructors give the newly created object a name with a number. For example, Tshirt 3 indicates that this is the 3rd Tshirt object. (This implies that you need to count how many objects you have for both classes.)
- Define the Stack class shown as the figure below:
- Define the StackTest class which contains a infinite loop for the user to make a choice to the laundry basket. See the demo clip here.
- Read more examples for upcasting and downcasting here. (Thanks to U. Texas)
- 2015.12.12
- 2015.12.13, solution
Sample Codes
As a beginner, avoid copying. Please write the code on your own.
Reading Material
Much material is available until 2015.12.16.
Grading Policy
- Programming Assignments (30 points)
- Final Exam (70 points)
You will get the certificate for this course if you acquire more than 70 points in total.