CS 112 – Introduction to Computing II
9/15/16
CS 112 ? 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
The fundamental data type in Python is a list, which stores a list of values:
Computer Science
Python:
2
1
9/15/16
Java Data Types: Array
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:
Computer Science
Python:
Java:
Same: Access elements using [ ... ]
3
Java Data Types: Array
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:
Computer Science
Python:
Java:
Same: Access elements using [ ... ] Indices range from 0 ... length ? 1 For loop used to run through entire array
4
2
9/15/16
Java Data Types: Array
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:
Computer Science
Python:
Java:
Same: Access elements using [ ... ]
Indices range from 0 ... length ? 1
For loop used to run through entire array
Error if index is not in range.
5
Java Data Types: Array
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:
Computer Science
Python:
Java:
Not same: Initialize array using { ... } instead of [ ... ]
6
3
9/15/16
Java Data Types: Array
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:
Computer Science
Python:
Java:
B = [ 4, "hi there", 2.3, True ]
Not same: Initialize array using { ... } instead of [ ... ] Must declare with array type with [ ] and all elements must be of same type.
7
Java Data Types: Array
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:
Computer Science
Python:
Java:
B = [ 4, "hi there", 2.3, True ]
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
Same: We can change the value in a particular location in the sequence:
Python:
Java:
Computer Science
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
- computational physics python programming
- cs229 python numpy
- basic python programming for loops and reading files
- a beginners guide to arrays and do loops
- cs 112 introduction to computing ii
- bob dowling university computing service
- python nump and park
- programming for gcse topic 6 1 lists arrays and for loop
- python programing an introduction to computer science
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