CS 112 – Introduction to Computing II
9/15/16
CS 112 ¨C Introduction to Computing II
Wayne Snyder
Computer Science Department
Boston University
Today:
Arrays (1D and 2D)
Methods
Program structure
Fields vs local variables
Next time: Program structure continued: Classes and objects; public vs private; static vs
non-static objects;
Reading assignments will be posted on the web site!
Computer Science
Java Data Types: Array
Computer Science
The fundamental data type in Python is a list, which stores a list of
values:
Python:
2
1
9/15/16
Java Data Types: Array
Computer Science
The fundamental data type in Python is a list, which stores a list of
values; in Java, a sequence of values is stored in an array:
Python:
Java:
Same: Access elements using [ ¡ ]
3
Java Data Types: Array
Computer Science
The fundamental data type in Python is a list, which stores a list of
values; in Java, a sequence of values is stored in an array:
Python:
Java:
Same: Access elements using [ ¡ ]
Indices range from 0 ¡ length ¨C 1
For loop used to run through entire array
4
2
9/15/16
Java Data Types: Array
Computer Science
The fundamental data type in Python is a list, which stores a list of
values; in Java, a sequence of values is stored in an array:
Python:
Java:
Same: Access elements using [ ¡ ]
Indices range from 0 ¡ length ¨C 1
For loop used to run through entire array
Error if index is not in range.
5
Java Data Types: Array
Computer Science
The fundamental data type in Python is a list, which stores a list of
values; in Java, a sequence of values is stored in an array:
Python:
Java:
Not same: Initialize array using { ¡ } instead of [ ¡ ]
6
3
9/15/16
Java Data Types: Array
Computer Science
The fundamental data type in Python is a list, which stores a list of
values; in Java, a sequence of values is stored in an array:
Python:
Java:
Not same: Initialize array using { ¡ } instead of [ ¡ ]
Must declare with array type with [ ] and
all elements must be of same type.
7
B = [ 4, ¡°hi there¡±, 2.3, True ]
Java Data Types: Array
Computer Science
The fundamental data type in Python is a list, which stores a list of
values; in Java, a sequence of values is stored in an array:
Python:
B = [ 4, ¡°hi there¡±, 2.3, True ]
Java:
Not same: Initialize array using { ¡ } instead of [ ¡ ]
Must declare with array type with [ ] and
all elements must be of same type.
Length of array is name-of-array.length
4
9/15/16
Java Data Types: Array
Computer Science
Same: We can change the value in a particular location in the
sequence:
Python:
Java:
9
Java Data Types: Array
Computer Science
Not same: We can NOT change the size of the sequence at run time,
as we can in Python:
Python:
Java:
SIMPLY NOT POSSIBLE!
10
5
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- solving a 2d maze university of alaska system
- arrays and matrices unibz
- eigen tutorial github pages
- chapter 7 multidimensional arrays
- 2d arrays 2d arrays and double pointers bryn mawr
- cambridge international examinations cambridge
- unordered data structures sets and maps put your answers
- 2 1 1 2 2 2 2 3 4 algorithm flowcharts programming
- 08 0 arrays 08 1
- two dimensional arrays
Related searches
- introduction to financial management pdf
- introduction to finance
- introduction to philosophy textbook
- introduction to philosophy pdf download
- introduction to philosophy ebook
- introduction to marketing student notes
- introduction to marketing notes
- introduction to information systems pdf
- introduction to business finance pdf
- introduction to finance 15th edition
- introduction to finance books
- introduction to finance online course