XJTLU_CPT111_JAVA PROGRAMMING 笔记-程序员宅基地

技术标签: 笔记  java  

全部内容看这里(以这两个版本为准)

Word版>> 百度网盘链接 <<

Blog版>>个人博客链接<<

*推荐一下隔壁朋友的CPT101笔记一文带你速通CPT101计算机系统概念(含笔记下载链接)-程序员宅基地 *

前言

本课程CPT111对于毫无编程基础和编程思想的小白来说有一定难度,在后面的课程十分凌乱和跳跃。如果说想只通过本课程掌握Java,这是错误的,如果说只通过某些大众JAVA网课学习来学习本课程,这是困难且耗时的。可以理解为,本课程类似于制定游戏规则,而你在游戏规则下get higher score。谨记从上课材料和上课要求的库出发解决问题,多写多练多讨论多花时间多用gpt和搜索引擎,相信你能获得一个不错的成绩。此外,英语学习是本课程最重要的部分之一。

本文并不能保证所有内容都为正确,有错误见谅。禁止任何商业目的的转载和摘编。(文中有很多超链接,按住ctrl点击访问)

本学期课程学分分布如下(平时分拿到了之后基本不挂科,但是高分难度很高)

小占比:Lab出勤签到+每周CW

大占比:学期中后CW大作业得分(CW3)+期末考试

2022年CW3的内容是制作一个DNA结构

2023年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 classdeclaration声明 

○ 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

int&float&double differents

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.Whats 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

//能进行一些常识判断即可

GDPR 7 princple

一般只考一题选择。

这里是课件。

>>>>END<<<<

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/Fancivoid/article/details/135682078

智能推荐

UE4的AI行为树基础知识_ue4行为树-程序员宅基地

文章浏览阅读1.4k次。UE4的AI基础学习_ue4行为树

【华为云技术分享】一文带你了解Web前端发展历程_华为云前端发版-程序员宅基地

文章浏览阅读2.5k次。摘要:自互联网行业发展以来,web前端不断发展变化着。在前人的基础上,后人有幸能够站在前人的肩膀上行走。前端的发展变化不仅是继承式的迭代,同时也是不断的变革和创造。一、前端到底是个什么?简单点说,浏览器呈现出来的页面,给用户看的、操作的就是前端(客户端);你看不到的,类似一些游戏数据、应用数据之类的就是后端(服务端)。那么再简单点就可以说,前端指的就是浏览器端,后端指的就是为浏览器提供服务和数据的服务器端。这是比较准确的描述,如果往大了讲,你所有看到的一切,网页、移动端网页、小程序、甚._华为云前端发版

MutationObserver - 监听Dom变化_mutationobserver.observe-程序员宅基地

文章浏览阅读783次,点赞18次,收藏26次。监听DOM变化(属性变动、目标子节点变化、观察后代节点等)_mutationobserver.observe

【C/C++】freopen 函数和 fopen 函数|标准输入输入写入文件|屏幕输出写入文件-程序员宅基地

文章浏览阅读9.8k次,点赞13次,收藏65次。freopen 和 fopen 都是C的标准库函数被包含于C标准库头文件中。fopen就是我们最熟悉的打开一个文件用于写入or读取freopen 是打开一个文件,用于接收输入输出流的数据。_freopen

python sys.path.append()和sys.path.insert()_sys. addpath-程序员宅基地

文章浏览阅读3.8k次。转载自: https://blog.csdn.net/dcrmg/article/details/79546962python程序中使用 import XXX 时,python解析器会在当前目录、已安装和第三方模块中搜索 xxx,如果都搜索不到就会报错。 使用sys.path.append()方法可以临时添加搜索路径,方便更简洁的import其他包和模块。这种方法导入的路径会在python程..._sys. addpath

Qt中的矩阵计算库eigen_qt矩阵运算-程序员宅基地

文章浏览阅读7.8k次,点赞7次,收藏44次。我的官网地址原文链接Qt中的矩阵计算库eigen在实际工程中由于需要使用矩阵计算,网上搜罗了下,发现 eigen 库比较靠谱,这里简要介绍下食用方法,以及如何避免运行断言下载库eigen 官网引入到 Qt 工程中将 源码中的 的 Eigen 目录拷贝到 Qt 工程的目录目录中新建 eigen.pri 文件内容如下INCLUDEPATH += $$PWD使用新建 C+..._qt矩阵运算

随便推点

BiLSTM双向长短期记忆神经网络回归预测算法(基于Matlab实现)_双向bilstm模型-程序员宅基地

文章浏览阅读539次,点赞11次,收藏9次。正向的LSTM网络接受序列数据的初始状态,逐步学习前向信息并更新内部隐藏状态,最终生成前向隐藏状态序列。反向的LSTM网络则以相反的顺序处理序列数据,并生成相应的反向隐藏状态序列。本文将介绍使用Matlab实现的BiLSTM算法,并展示其在多输入单输出回归问题上的应用。然后,我们定义了BiLSTM模型的层次结构,包括序列输入层、BiLSTM层、全连接层和回归层。与传统的单向LSTM相比,BiLSTM能够同时利用序列数据的前向和后向信息,从而提高模型在长期依赖关系上的学习能力。_双向bilstm模型

D78XX系列——用于各种电视机、收录机、电子仪器、设备的稳压电源电路,输出电流大,内设过热、短路保护电路,无需外接元件-程序员宅基地

文章浏览阅读295次,点赞9次,收藏11次。D78XX系列是用于各种电视机、收录机、电子仪器、设备的稳压电源电路。包括D7805、D7806、 D7808、 D7809、 D7810、 D7812、 D7815。● 输出电流大,IOMAX= 1A.● 封装形式: T0-220。● 内设过热、短路保护电路。

stm32入门学习(基于STM32F103C8T6)_stm32f103c8t6csdn-程序员宅基地

文章浏览阅读456次,点赞8次,收藏2次。じゃ、始めましょう。--最近在学外语,对于IT从业者来说,会是一项优势。_stm32f103c8t6csdn

Anaconda安装_anaconda环境变量e:\anaconda3\library\usr\bin-程序员宅基地

文章浏览阅读7.1k次,点赞41次,收藏196次。文章目录1.Anaconda是什么2.Anaconda下载3.Anaconda安装4.Anaconda环境变量配置5.检验是否安装成功6.检验Anaconda Navifator是否安装成功7.修改Anaconda镜像修改为清华大学镜像移除清华大学镜像8.PyCharm配置Anaconda方式一(建立新的项目时)方式二(已经打开项目)9.总结1.Anaconda是什么Anaconda指的是一个开源的Python发行版本,其包含了conda、Python等180多个科学包及其依赖项。Anaconda也是P_anaconda环境变量e:\anaconda3\library\usr\bin

70个常用电脑快捷键,帮你工作效率提升100倍!职场新人必备!_快捷键可以帮助自己-程序员宅基地

文章浏览阅读2k次,点赞11次,收藏44次。电脑快捷键不仅可以帮助我们熟练的操作电脑,还可以帮助我们快速提升自己的工作效率,从此跟加班说拜拜!但由于电脑快捷键过于繁多不方便我们记忆!那么今天小编为大家整理的70个Wordows、Ctrl、Alt、Shift组合快捷键,运用好的话能够帮你工作效率提升100倍!希望能为大家派上用途!下面以图片&amp;文字的形式展现给大家!文字可以直接复制!图片也可以直接拿去收藏!..._快捷键可以帮助自己

用HTML语言制作一个非常浪漫的生日祝福网,手把手教你制作炫酷生日祝福网页_用html做一个生日快乐网页-程序员宅基地

文章浏览阅读2.2w次,点赞317次,收藏636次。明天就是女朋友的生日了, 是时候展现专属于程序员的浪漫了!你打算怎么给心爱的人表达爱意?鲜花礼物?代码表白?还是创意DIY?或者…无论那种形式,快来秀我们一脸吧!_用html做一个生日快乐网页

推荐文章

热门文章

相关标签