全部内容看这里(以这两个版本为准)
Pdf版>> 百度网盘链接 <<
Blog版>>个人博客链接<<
推荐一下隔壁朋友的CPT101笔记一文带你速通CPT101计算机系统概念(含笔记下载链接)-CSDN博客
下学期ICS笔记请看这
23-24-ICS课程笔记汇总-github 里面未来会考虑添加CST的CPT108内容。
前言
本课程CPT111对于毫无编程基础和编程思想的小白来说有一定难度,在后面的课程十分凌乱和跳跃。如果说想只通过本课程掌握Java,这是错误的,如果说只通过某些大众JAVA网课学习来学习本课程,这是困难且耗时的。可以理解为,本课程类似于制定游戏规则,而你在游戏规则下get higher score。谨记从上课材料和上课要求的库出发解决问题,多写多练多讨论多花时间多用gpt和搜索引擎,相信你能获得一个不错的成绩。此外,英语学习是本课程最重要的部分之一。
本文并不能保证所有内容都为正确,有错误见谅。禁止任何商业目的的转载和摘编。(文中有很多超链接,按住ctrl点击访问)
本学期课程学分分布如下(平时分拿到了之后基本不挂科,但是高分难度很高)
小占比:Lab出勤签到+每周CW
大占比:学期中后CW大作业得分(CW3)+期末考试
23-24期末考试:形式:机考
内容:31道题。MCQs居多,定义&理论题占比大。大题除了一题递归其余都是填空(继承等..)注意上下大题可能会有关联。大题难度不高其实。
开卷考试:允许携带U盘(仅pdf文件)和纸质资料。(当时我携带的就是这份笔记!)
考试模式:考试时开启监控软件。只能使用四个窗口,LMO、两个编译器、PDF查看器。
我的评价:看懂理论题的英文>我会写代码🤡。(u1s1可以带一本字典)
修订于24/1/10
I.The first java class
1.First java program
public class Hello {
public static void main(String[] args) {
System.out.println("Hello World");
}
}
Output:Hello world
2.Java Virtual Machine (JVM)
New project 后大概如图所示 src是文件目录 以下是创建文件示意图
3.Which PART?
class / main method / statement / semicolon / braces / squared / brackets / parentheses / parameter
public class Hello { //class
public static void main(String[] args) { //main method
System.out.println("Hello World"); //statement
} //parentheses圆括号 parameter参数
} //semicolon 分号 braces大括号 squared方括号brackets中括号
4.Object-Oriented Language
面向对象设计语言:JAVA
Java is an Object-Oriented Language:
○ every Java file must contain a class类declaration声明
○ all code代码 is written inside在 a class 类
○ to run a Java program, need to define a main method定义主方法
5.IN-first class-quiz
public class Hello {
public static void main(String[] args) {
int num = 5;
num = num + num;
System.out.println(num);
}
}
The input is 10.
6.TIPS:
○ single quote \' 单引号’
○ double quote \" 双引号”
○ new line character \n 新一行Enter
○ backslash \\ 反斜线\
7.For Example
7 + 4 = num1
6 + 4 = num2
System.out.println(‘\’num1 + num2 = ‘ + (num1 +num2) + ‘\’’)
INPUT ‘num1 + num2 = 21’
Println输出换行 print 输出接上
8.Binary, Bit and Bytes
To a modern computer, everything is binary
○ 1 bit is 1 binary digit: 0 or 1 ; ON or OFF ; TRUE or FALSE
● Every bit we add doubles the total we can represent
○ 1 bit – 2
○ 2 bits – 4
○ 3 bits – 8
○ 4 bits – 16
○ ...
○ 8 bits – 256 – one Byte
● Mathematically: n bits yields 2n patterns (2 to the n-th power)
○3 Ways to Convert from Decimal to Binary - wikiHow
8 bits = 1 byte ≈ often 1 character, e.g. "a"
1024 bytes = 1 kilobyte ≈ several paragraphs
1024 kilobytes = 1 Megabyte ≈ about 200 pages of text
1024 Megabytes = 1 Gigabyte ≈ 256 MP3 files
1024 Gigabytes = 1 Terabyte ≈ 40 large movies
9.Hexadecimal
● Base 16 numbering system
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
● Represented with 0x__
i.e. 255 in decimal is 0xFF
● More readable than binary 比二进制更可读
decimal 121 10进制
binary 01111001 2进制
hex 0x79 16进制
● Stores more information than binary 存储比二进制文件更多的信息
hex and binary relate well 十六进制和二进制之间的关系很好
1 hex digit can always be represented with 4 binary digits 1个十六进制数字总是可以用4个二进制数字表示
no relationship like this between decimal and binary
10.24-bit Colour
● 24-bit colour means that there are
24 bits allocated for RGB channels
为RGB通道分配了24位
○ 8 bits for red, 8 bits for green,
8 bits for blue 红绿蓝
● How to represent this colour purple?
○ rich purple? deep purple?
● Need a better representation
○ often use hexadecimal 0xd400ff
○ what does that mean? 0x是十六进制的开头
● Hex 0xd400ff
○ d4 – red bits
○ 00 – green bits
○ ff – blue bits
● Compact, as opposed to 24-bit value for this colour purple
○ 110101000000000011111111
11.ASCII – American Standard Code for Information Interchange
● Recall, computers can only store binary
○ includes characters
● ASCII is an encoding scheme 编码方案
that represents each character
with a 7-bit value
12.What’s Java?
●Created by James Gosling
Modern object-oriented language
Continuously improved since 1990s
● Widely used
Mars rover, cell phones, web servers, ...
● Unfortunately, Java is verbose
Using more words – compare with Python!
● More importantly, it is not about the language
The programming skills that you learn in this course will apply to many Languages
13.JAVA basic principle
Case sensitive:Java is case sensitive, This means that the identifier Hello is different from the hello. 大小写区分
Class name: For all classes, the initials of the class name should be capitalized. If the class name consists of several words, then the first letter of each word should be capitalized, such as MyFirstJavaClass. 类名命名:每个单词首字母大写
Method name: All method names should start with lowercase letters. If the method name contains a number of wordm90 |s, the following first word is capitalized. 方法名命名:小写字母开头,但是若干单词后面每个单词首字母大写
Source file name: The source file name must be the same as the class name. When saving a file, you should save the class name as a file name (remember that Java is case sensitive), and the file name is 后缀suffix. java.(If the file name is not the same class name).文件名必须是类名
Main method entry: All Java programs are executed starting by the public static void main (String [] args) method.(所有程序必须从该方法开始执行)
II.The second class
14.JAVA data types
Java data types - integer data 整数数据
Integers (to non-mathematicians) are whole numbers, numbers with no fractional part, no decimal point. 以下四种
1.byte
8 bits -128 to 127 (0 to 255)
Bytes. e.g., individual bytes of image data; in 32 bit images there is 1 byte each for red, green, blue and alpha (transparency) 字节数。例如,图像数据的单个字节;在32位图像中,红、绿、蓝和alpha(透明度)各有一个字节
2.short
16 bits -32,768 to 32,767
To save memory – instead of int. However, in most JVMs they are 32-bit anyway, so useless. 要保存内存-而不是int。然而,在大多数jvm中,它们都是32位的,非常没用。
3.int (default)
32 bits -2^31 to 2^31 - 1
Everything except very big/very negative values. This is the default. 除了非常大的/非常负的值。这是默认值。
4.long
64 bits -2^63 to 2^63-1
long bigNumber = 300000000000000000L;
You will probably use int 95%+ of the time, long sometimes, and byte occasionally. 实用度 int>long>byte
Java data types - floating point非整数
1.float
32 bits
+-10^38 approx. 7 significant digits (decimal) float f = 1.375f;
2.double
64 bits +-10^38 approx. 15 significant digits (decimal) Default
e.g.
int a = 1000000000;
long b = 1000000000000000000l;
double c = 31.32;
float d = 31.01f;
Java data types - Strings
Strings
As introduced last week, can also use Strings
Strings are objects, and have many methods
○ At basic level, can store text data
○ Note, double quotes needed around string
E.g. String str = "This is a String";
char
represents a character ('a', 'b', 'c', etc)
A different data type
includes non-Roman characters (Chinese, Cyrillic, Arabic, Greek
etc)
○ It is actually a 16 bit integer, range 0 - 65,535
Java data types - Boolean
● We can also store True/False information
Boolean
(means true or false)
Discussed later in the module
Cannot store anything except this
Very useful for checking if conditions are met
Its size varies; it only uses 1 bit, but can take up to 32 bits of memory!
boolean bool = false;
>>全部内容看这里>> 百度网盘链接 <<(或者等我自己搭博客(X))<<懒得打
15.Assigning variables
*declaration 声明 definition 定义 initialization初始化 assignment赋值 区分
16.Arithmetic operators 算子
17.Java Arithmetic 计算实战
18.Unary Operators
19.mathematical function
20.Triangles - Hypotenuse
21. Angles of triangle
22.Initial Programming
23.The Scanner Object
24.Convert data type
25.Good programming style
26.Lab learning
27.CW1&CW2 learning
JAVA编程中source code和bytecode有什么区别
编译器和解释器之间有什么区别
28.Boolean Operators
29.if statement
30.While statement
31.For statement
32.break
33.loop
34.Store a group
35.Methods
36.Java function
37.Scop
38.Method Signature
39.Char
40.Object Oriented Programming
1.(static final关键字)
2.Primitive data types (int, double, boolean etc.) store an actual value
3.Primitives have no methods
4.Wrapper Classes 包装类
”Integer.toString(3)”
5.Object的理解
6.String Methods
7.Data Objects
8.Instance variables
9.包的引用
10.Create a constructor
11.This
12.Different classes
13.Public and Private
14.Encapsulation
15.Primitive variables and Object variables
16.== and .equals()
17. .toString() method
41.Review
Instance Variable实例变量
Constructor 构造器
Test Client, Object Instantiation 测试客户端,对象实例化
Reference Type 引用类型
Private 私有变量
ToString() Method
Getter and Setter
Instance Method
Method Overloading
Constructors Overloading
Static Method / Function
Class Variable / Static Variable
Accessing Class Variable
Array of Objects
42.Inheritance 继承
Subclass and Superclass
43.Final Instance Variable
44.@Override Annotation
45. Polymorphism
46.E.G
47.Review
1.Encapsulation
2.Review: Overloading
3.Inheritance
4.Overriding
5.Polymorphism
6.In-Class Quiz 9.7: Polymorphism
7.In-Class Quiz 9.6: Overriding (The reason of 95)
48.Protected key word
49.dynamic type / static type
50.Exception
Exception 1:ArrayIndexOutOfBoundsException
Exception 2:Runtime Error
Exception 3:Throwing exception object
Catching an exception object 1
51.creating, writing to and reading from a file
Data
Absolute file name
Relative file name
52.File Methods
53.Creating a new file using PrintWriter
54.PrintWriter
55.In-Class Quiz 10.1
56.BufferedWriter
57.Using Scanner
58.Reading csv data using Scanner
59.GUI with JavaFX
1.JavaFX Advantages
2.Say hello to the GUI world
3.Button in a Pane
4.Circle
5.Color
6.Font, Label and StackPane
7.Image and ImageView
8.Layout Panes
9.Shapes
10.Text
11.Line
12.Rectangle
13.Ellipse
14.Arc
15. Polygon and Polyline
16.Lab
Task1
Task2
60.List
61.Set
62.Map
63.Recursion
64.Data Protection, Ethics and Professional issue
//能进行一些常识判断即可
一般只考一题选择。