Pointers (Discussion 2) (Con trỏ và danh sách liên kết) - Christine Zhou
- Seiten
- 12
- Định dạng
- PPTX
- Dung lượng
- 327 KB
- Trường
- University of California, Berkeley
- Aufrufe
- 0
- Kommentare
- 0
- Lượt tải
- 0
Vorschau wird generiert...
Tài liệu thảo luận về con trỏ và danh sách liên kết (IntList) trong Java, bao gồm ôn tập và các bài tập về biểu diễn hộp và con trỏ, chèn, đảo ngược và dịch chuyển danh sách.
- Dokumentenname
- Pointers (Discussion 2) (Con trỏ và danh sách liên kết) - Christine Zhou
- Schule / Kurs
- University of California, Berkeley · Lập trình Java
- Inhalt
- Tài liệu này giới thiệu về con trỏ trong Java, phân biệt kiểu dữ liệu nguyên thủy và tham chiếu, và hướng dẫn sử dụng sơ đồ Hộp và Con trỏ. Nó cung cấp các bài tập thực hành về thao tác trên danh sách liên kết như chèn, đảo ngược và dịch chuyển.
- Inhaltsverzeichnis
- Agenda
- Announcements
- Review
- Worksheet
- Review: Defining Classes
- Review: Primitives and Reference Types
- Review: Box and Pointer Diagrams
- 1. Boxes and Pointers
- 2. Insertion
- 3. Reverse
- 4. Shifting a Linked List
- Seiten
- 12 Seiten
- Hochgeladen von
- Uni24h
Beschreibung
Trích nội dung tài liệu
Discussion 2: Pointers Christine Zhou Agenda Announcements Review Worksheet Announcements Happy three-day weekend! HW1 due Friday 9/8 Proj0 due Tuesday 9/18 Get started ASAP! Labs are due at midnight on Fridays Discussion survey: tinyurl.com/czdisc2 Review: Defining Classes // class definition public class IntList { // instance variables int head; IntList tail; // constructors, which will create IntList objects public IntList() {...} public IntList(int value, IntList tail) {...} // you can create methods that use the instance variables! public void insert(int val) {...} public void removeLast() {...} } Review: Primitives and Reference Types Two types of values: primitives and reference types 8 primitive types: char, boolean, int, double, float, byte, short, long All others are reference types (Strings, self-defined classes like IntList) Pass-by-value When Java creates a primitive type value, it will create a box and store that primitive value in the box When Java creates a reference type value, it will create a box and store the pointer to the reference type value (the value in the box will be the address of the object in memory) Review: Box and Pointer Diagrams Will be very helpful in keeping track of everything! Small example with an int and a Potato object (with an int age and a String variety) Review: Box and Pointer Diagrams Let’s try a small example with the IntList we defined a few slides ago. Draw the B&P for the following code: IntList lst1 = new IntList(1, null); lst1 = new IntList(2, lst1); IntList lst2 = new IntList(3, null); lst2 = new IntList(4, lst2); lst2.head = lst1.head; lst2.tail = lst1.tail; Take the value living inside the box that we’re looking for, and then do the reassignment (pass-by-value of the box) 1. Boxes and Pointers Draw a box and pointer diagram to represent the IntLists after each statement. IntList L = IntList.list(1, 2, 3, 4); IntList M = L.tail.tail; IntList N = IntList.list(5, 6, 7);
Häufig gestellte Fragen
Ist dieses Dokument kostenlos?
Ja. „Pointers (Discussion 2) (Con trỏ và danh sách liên kết) - Christine Zhou“ ist kostenlos — melden Sie sich einfach an und klicken Sie auf Herunterladen, um die Originaldatei zu erhalten.
Wie viele Seiten hat dieses Dokument?
Das Dokument hat 12 Seiten, für den Kurs Lập trình Java. Sie können es vor dem Herunterladen online in der Vorschau ansehen.
Kann ich vor dem Herunterladen eine Vorschau ansehen?
Ja. Sie können sich dieses Dokument direkt auf dieser Seite im Online-Reader ansehen und dann entscheiden, ob Sie es herunterladen möchten.
Pointers (Discussion 2) (Con trỏ và danh sách liên kết) - Christine Zhou
Vorschau wird generiert...
Trích nội dung tài liệu
Discussion 2: Pointers Christine Zhou Agenda Announcements Review Worksheet Announcements Happy three-day weekend! HW1 due Friday 9/8 Proj0 due Tuesday 9/18 Get started ASAP! Labs are due at midnight on Fridays Discussion survey: tinyurl.com/czdisc2 Review: Defining Classes // class definition public class IntList { // instance variables int head; IntList tail; // constructors, which will create IntList objects public IntList() {...} public IntList(int value, IntList tail) {...} // you can create methods that use the instance variables! public void insert(int val) {...} public void removeLast() {...} } Review: Primitives and Reference Types Two types of values: primitives and reference types 8 primitive types: char, boolean, int, double, float, byte, short, long All others are reference types (Strings, self-defined classes like IntList) Pass-by-value When Java creates a primitive type value, it will create a box and store that primitive value in the box When Java creates a reference type value, it will create a box and store the pointer to the reference type value (the value in the box will be the address of the object in memory) Review: Box and Pointer Diagrams Will be very helpful in keeping track of everything! Small example with an int and a Potato object (with an int age and a String variety) Review: Box and Pointer Diagrams Let’s try a small example with the IntList we defined a few slides ago. Draw the B&P for the following code: IntList lst1 = new IntList(1, null); lst1 = new IntList(2, lst1); IntList lst2 = new IntList(3, null); lst2 = new IntList(4, lst2); lst2.head = lst1.head; lst2.tail = lst1.tail; Take the value living inside the box that we’re looking for, and then do the reassignment (pass-by-value of the box) 1. Boxes and Pointers Draw a box and pointer diagram to represent the IntLists after each statement. IntList L = IntList.list(1, 2, 3, 4); IntList M = L.tail.tail; IntList N = IntList.list(5, 6, 7);
- Dokumentenname
- Pointers (Discussion 2) (Con trỏ và danh sách liên kết) - Christine Zhou
- Schule / Kurs
- University of California, Berkeley · Lập trình Java
- Inhalt
- Tài liệu này giới thiệu về con trỏ trong Java, phân biệt kiểu dữ liệu nguyên thủy và tham chiếu, và hướng dẫn sử dụng sơ đồ Hộp và Con trỏ. Nó cung cấp các bài tập thực hành về thao tác trên danh sách liên kết như chèn, đảo ngược và dịch chuyển.
- Inhaltsverzeichnis
- Agenda
- Announcements
- Review
- Worksheet
- Review: Defining Classes
- Review: Primitives and Reference Types
- Review: Box and Pointer Diagrams
- 1. Boxes and Pointers
- 2. Insertion
- 3. Reverse
- 4. Shifting a Linked List
- Seiten
- 12 Seiten
- Hochgeladen von
- Uni24h
Kommentare (0)
Noch keine Kommentare. Seien Sie der Erste!
Java DataBase Connectivity - Kết nối kho dữ liệu Java
Ôn tập lập trình Java (MT2 Review Solutions) - Ching and Christines
Asymptotics II, Search Trees (Discussion 7) (Kỹ thuật phân tích thời gian chạy, cây tìm kiếm nhị phân) - Christine Zhou
Introduction to Java (Discussion 1) (Giới thiệu về Java) - Christine Zhou
Giáo trình Lập trình Java
Tổng hợp Đề Toán 5 - Luyện thi vào Lớp 6 - CLB EMath
Bài giảng vật lý đại cương (Chương 3) - Đỗ Ngọc Uấn
Chương 8.Nguyên tử - Vật lý đại cương 3 - TS.Nguyễn Thị Trang
Chương 7.Cơ học lượng tử - Vật lý đại cương 3 - TS.Nguyễn Thị Trang
Chương 6.Quang học lượng tử - Vật lý đại cương 3 - TS.Nguyễn Thị Trang

Kommentare (0)
Noch keine Kommentare. Seien Sie der Erste!