Scope, Pass by Value, Static (Discussion 2) (Phạm vi, truyền tham trị và từ khóa static trong Java) - Christine Zhou
Generating preview...
Tài liệu thảo luận về phạm vi, truyền tham trị và từ khóa static trong Java, kèm ôn tập danh sách liên kết và sơ đồ box-and-pointer.
Description
Discussion 2: Scope, Pass-byValue, Static Christine Zhou Agenda Announcements Worksheet #1 Worksheet #2 Worksheet #3 (if we can!) Administrivia Lab 1 and Lab 2 due this Friday 2/1 at midnight. ○ Note, all labs are due Friday at midnight the week they are assigned. Proj0 NBody also due Friday at midnight. ○ If you haven’t started please start ASAP! Office hours and exam prep/LOST sections start this week! See calendars on the course website. Pre-semester Advising: @414 or email me! Discussion survey: http://tinyurl.com/cz-disc2-sp19 ○ Good for me to collect your emails (in case I have announcements or mess up during discussion 😅) 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: Java’s Types Primitives: References: byte, short, long, int, double, float, char, boolean Everything else! Objects, arrays, Strings, etc. Review: Box and Pointer Diagrams Box and Pointers are the 61B equivalent of 61A’s environment diagram They are crucial to helping us keep track of what goes on in a program: use them! int x = 29; int x 29 Primitives go in the box int[] arr = new int[3]; We didn’t specify what integers are going in the array, so Java initializes it with the default value 0 int[ ] arr 0 0 0 Reference types are referenced via pointers Java is pass by value Golden Rule of Equals AKA pass-by-value When you do “a = b”, you always copy the bits (whatever is inside the box) of b into a. For primitives: Directly copy the value inside b to a. For Reference types: Copy the memory address of b into a. ○ Also can say “copies the pointer in b to a” int[ ] arr1 int x = 29; int y = x; int x int y 29 29 int[] arr1 = new int
AI summary
- Document name
- Scope, Pass by Value, Static (Discussion 2) (Phạm vi, truyền tham trị và từ khóa static trong Java) - Christine Zhou
- School / Course
- University of California, Berkeley · Lập trình Java
- Content
- Tài liệu thảo luận về phạm vi, truyền tham trị và các thành phần tĩnh trong Java, kèm theo các ví dụ và bài tập thực hành về định nghĩa lớp, kiểu dữ liệu và cấu trúc dữ liệu IntList.
- Table of contents
- Agenda
- Announcements
- Administrivia
- Review: Defining classes
- Review: Java’s Types
- Review: Box and Pointer Diagrams
- Java is pass by value
- 1) Pass by What?
- Review: Static Variables/Methods
- 2) Static Methods and Variables
- Review: IntLists
- 3) Practice with Linked Lists
- 4) Extra: Squaring a List
- Pages
- 15 pages
- Uploaded by
- Uni24h
Frequently asked questions
Is this document free?
Yes. “Scope, Pass by Value, Static (Discussion 2) (Phạm vi, truyền tham trị và từ khóa static trong Java) - Christine Zhou” is free — just sign in and click Download to get the original file.
How many pages is this document?
The document has 15 pages, for the course Lập trình Java. You can preview it online before downloading.
Can I preview before downloading?
Yes. You can preview this document right on this page with the online reader, then decide whether to download.
Scope, Pass by Value, Static (Discussion 2) (Phạm vi, truyền tham trị và từ khóa static trong Java) - Christine Zhou
Generating preview...
Discussion 2: Scope, Pass-byValue, Static Christine Zhou Agenda Announcements Worksheet #1 Worksheet #2 Worksheet #3 (if we can!) Administrivia Lab 1 and Lab 2 due this Friday 2/1 at midnight. ○ Note, all labs are due Friday at midnight the week they are assigned. Proj0 NBody also due Friday at midnight. ○ If you haven’t started please start ASAP! Office hours and exam prep/LOST sections start this week! See calendars on the course website. Pre-semester Advising: @414 or email me! Discussion survey: http://tinyurl.com/cz-disc2-sp19 ○ Good for me to collect your emails (in case I have announcements or mess up during discussion 😅) 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: Java’s Types Primitives: References: byte, short, long, int, double, float, char, boolean Everything else! Objects, arrays, Strings, etc. Review: Box and Pointer Diagrams Box and Pointers are the 61B equivalent of 61A’s environment diagram They are crucial to helping us keep track of what goes on in a program: use them! int x = 29; int x 29 Primitives go in the box int[] arr = new int[3]; We didn’t specify what integers are going in the array, so Java initializes it with the default value 0 int[ ] arr 0 0 0 Reference types are referenced via pointers Java is pass by value Golden Rule of Equals AKA pass-by-value When you do “a = b”, you always copy the bits (whatever is inside the box) of b into a. For primitives: Directly copy the value inside b to a. For Reference types: Copy the memory address of b into a. ○ Also can say “copies the pointer in b to a” int[ ] arr1 int x = 29; int y = x; int x int y 29 29 int[] arr1 = new int
Read full document
- Document name
- Scope, Pass by Value, Static (Discussion 2) (Phạm vi, truyền tham trị và từ khóa static trong Java) - Christine Zhou
- School / Course
- University of California, Berkeley · Lập trình Java
- Content
- Tài liệu thảo luận về phạm vi, truyền tham trị và các thành phần tĩnh trong Java, kèm theo các ví dụ và bài tập thực hành về định nghĩa lớp, kiểu dữ liệu và cấu trúc dữ liệu IntList.
- Table of contents
- Agenda
- Announcements
- Administrivia
- Review: Defining classes
- Review: Java’s Types
- Review: Box and Pointer Diagrams
- Java is pass by value
- 1) Pass by What?
- Review: Static Variables/Methods
- 2) Static Methods and Variables
- Review: IntLists
- 3) Practice with Linked Lists
- 4) Extra: Squaring a List
- Pages
- 15 pages
- Uploaded by
- Uni24h
Comments (0)
No comments yet. Be the first!
Misc.onclusion (Discussion 14-END) (Ôn tập cấu trúc dữ liệu) - Christine Zhou
Final Review Solutions (Cấu trúc dữ liệu heap, hàng đợi ưu tiên và duyệt đồ thị) - Ching and Christines
Giáo trình Lập trình Java
Inheritance (Discussion 4) (Kế thừa trong Java) - Christine Zhou
Asymptotic Analysis (Discussion 7) (Phân tích tiệm cận) - Christine Zhou
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
Chương 5.Thuyết tương đối - Vật lý đại cương 3 - TS.Nguyễn Thị Trang
Chương 4. Tán xạ ánh sáng - Vật lý đại cương 3 - TS.Nguyễn Thị Trang
Chương 3.Phân cực ánh sáng - Vật lý đại cương 3 - TS.Nguyễn Thị Trang
Comments (0)
No comments yet. Be the first!