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

智能推荐

5个超厉害的资源搜索网站,每一款都可以让你的资源满满!_最全资源搜索引擎-程序员宅基地

文章浏览阅读1.6w次,点赞8次,收藏41次。生活中我们无时不刻不都要在网站搜索资源,但就是缺少一个趁手的资源搜索网站,如果有一个比较好的资源搜索网站可以帮助我们节省一大半时间!今天小编在这里为大家分享5款超厉害的资源搜索网站,每一款都可以让你的资源丰富精彩!网盘传奇一款最有效的网盘资源搜索网站你还在为找网站里面的资源而烦恼找不到什么合适的工具而烦恼吗?这款网站传奇网站汇聚了4853w个资源,并且它每一天都会持续更新资源;..._最全资源搜索引擎

Book类的设计(Java)_6-1 book类的设计java-程序员宅基地

文章浏览阅读4.5k次,点赞5次,收藏18次。阅读测试程序,设计一个Book类。函数接口定义:class Book{}该类有 四个私有属性 分别是 书籍名称、 价格、 作者、 出版年份,以及相应的set 与get方法;该类有一个含有四个参数的构造方法,这四个参数依次是 书籍名称、 价格、 作者、 出版年份 。裁判测试程序样例:import java.util.*;public class Main { public static void main(String[] args) { List <Book>_6-1 book类的设计java

基于微信小程序的校园导航小程序设计与实现_校园导航微信小程序系统的设计与实现-程序员宅基地

文章浏览阅读613次,点赞28次,收藏27次。相比于以前的传统手工管理方式,智能化的管理方式可以大幅降低学校的运营人员成本,实现了校园导航的标准化、制度化、程序化的管理,有效地防止了校园导航的随意管理,提高了信息的处理速度和精确度,能够及时、准确地查询和修正建筑速看等信息。课题主要采用微信小程序、SpringBoot架构技术,前端以小程序页面呈现给学生,结合后台java语言使页面更加完善,后台使用MySQL数据库进行数据存储。微信小程序主要包括学生信息、校园简介、建筑速看、系统信息等功能,从而实现智能化的管理方式,提高工作效率。

有状态和无状态登录

传统上用户登陆状态会以 Session 的形式保存在服务器上,而 Session ID 则保存在前端的 Cookie 中;而使用 JWT 以后,用户的认证信息将会以 Token 的形式保存在前端,服务器不需要保存任何的用户状态,这也就是为什么 JWT 被称为无状态登陆的原因,无状态登陆最大的优势就是完美支持分布式部署,可以使用一个 Token 发送给不同的服务器,而所有的服务器都会返回同样的结果。有状态和无状态最大的区别就是服务端会不会保存客户端的信息。

九大角度全方位对比Android、iOS开发_ios 开发角度-程序员宅基地

文章浏览阅读784次。发表于10小时前| 2674次阅读| 来源TechCrunch| 19 条评论| 作者Jon EvansiOSAndroid应用开发产品编程语言JavaObjective-C摘要:即便Android市场份额已经超过80%,对于开发者来说,使用哪一个平台做开发仍然很难选择。本文从开发环境、配置、UX设计、语言、API、网络、分享、碎片化、发布等九个方面把Android和iOS_ios 开发角度

搜索引擎的发展历史

搜索引擎的发展历史可以追溯到20世纪90年代初,随着互联网的快速发展和信息量的急剧增加,人们开始感受到了获取和管理信息的挑战。这些阶段展示了搜索引擎在技术和商业模式上的不断演进,以满足用户对信息获取的不断增长的需求。

随便推点

控制对象的特性_控制对象特性-程序员宅基地

文章浏览阅读990次。对象特性是指控制对象的输出参数和输入参数之间的相互作用规律。放大系数K描述控制对象特性的静态特性参数。它的意义是:输出量的变化量和输入量的变化量之比。时间常数T当输入量发生变化后,所引起输出量变化的快慢。(动态参数) ..._控制对象特性

FRP搭建内网穿透(亲测有效)_locyanfrp-程序员宅基地

文章浏览阅读5.7w次,点赞50次,收藏276次。FRP搭建内网穿透1.概述:frp可以通过有公网IP的的服务器将内网的主机暴露给互联网,从而实现通过外网能直接访问到内网主机;frp有服务端和客户端,服务端需要装在有公网ip的服务器上,客户端装在内网主机上。2.简单的图解:3.准备工作:1.一个域名(www.test.xyz)2.一台有公网IP的服务器(阿里云、腾讯云等都行)3.一台内网主机4.下载frp,选择适合的版本下载解压如下:我这里服务器端和客户端都放在了/usr/local/frp/目录下4.执行命令# 服务器端给执_locyanfrp

UVA 12534 - Binary Matrix 2 (网络流‘最小费用最大流’ZKW)_uva12534-程序员宅基地

文章浏览阅读687次。题目:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=93745#problem/A题意:给出r*c的01矩阵,可以翻转格子使得0表成1,1变成0,求出最小的步数使得每一行中1的个数相等,每一列中1的个数相等。思路:网络流。容量可以保证每一行和每一列的1的个数相等,费用可以算出最小步数。行向列建边,如果该格子是_uva12534

免费SSL证书_csdn alphassl免费申请-程序员宅基地

文章浏览阅读504次。1、Let's Encrypt 90天,支持泛域名2、Buypass:https://www.buypass.com/ssl/resources/go-ssl-technical-specification6个月,单域名3、AlwaysOnSLL:https://alwaysonssl.com/ 1年,单域名 可参考蜗牛(wn789)4、TrustAsia5、Alpha..._csdn alphassl免费申请

测试算法的性能(以选择排序为例)_算法性能测试-程序员宅基地

文章浏览阅读1.6k次。测试算法的性能 很多时候我们需要对算法的性能进行测试,最简单的方式是看算法在特定的数据集上的执行时间,简单的测试算法性能的函数实现见testSort()。【思想】:用clock_t计算某排序算法所需的时间,(endTime - startTime)/ CLOCKS_PER_SEC来表示执行了多少秒。【关于宏CLOCKS_PER_SEC】:以下摘自百度百科,“CLOCKS_PE_算法性能测试

Lane Detection_lanedetectionlite-程序员宅基地

文章浏览阅读1.2k次。fromhttps://towardsdatascience.com/finding-lane-lines-simple-pipeline-for-lane-detection-d02b62e7572bIdentifying lanes of the road is very common task that human driver performs. This is important ..._lanedetectionlite

推荐文章

热门文章

相关标签