Java for Beginners Level 6 University Greenwich Computing At School

Slides:



Advertisements
Similar presentations
Introduction to C Programming
Advertisements

Introduction to Application Programming IST 256 Application Programming for Information Systems Xiaozhong Liu
Programming with Collections Collections in Java Using Arrays Week 9.
Computer Science 1620 Multi-Dimensional Arrays. we used arrays to store a set of data of the same type e.g. store the assignment grades for a particular.
Lists in Python.
Java for Beginners University Greenwich Computing At School DASCO
Chapter 8 Arrays and Strings
Array Cs212: DataStructures Lab 2. Array Group of contiguous memory locations Each memory location has same name Each memory location has same type a.
How to start Visual Studio 2008 or 2010 (command-line program)
Computer Programming 12 Mr. Jean April 24, The plan: Video clip of the day Upcoming Quiz Sample arrays Using arrays More about arrays.
Week # 2: Arrays.  Data structure  A particular way of storing and organising data in a computer so that it can be used efficiently  Types of data.
Trinity College Dublin, The University of Dublin GE3M25: Computer Programming for Biologists Python, Class 4 Karsten Hokamp, PhD Genetics TCD, 01/12/2015.
Introducing Arrays. Too Many Variables?  Remember, a variable is a data structure that can hold a single value at any given time.  What if I want to.
1 Chapter 9 Arrays Java Programming from Thomson Course Tech, adopted by kcluk.
Week 6 - Friday.  What did we talk about last time?  Loop examples.
Arrays Declaring arrays Passing arrays to functions Searching arrays with linear search Sorting arrays with insertion sort Multidimensional arrays Programming.
1 Chapter 9 Arrays Java Programming from Thomson Course Tech, adopted by kcluk.
Chapter 9 Arrays. Chapter Objectives Learn about arrays Explore how to declare and manipulate data into arrays Understand the meaning of “array index.
Chapter 9 Introduction to Arrays Fundamentals of Java.
1 Arrays and Variable Length Parameter List  The syntax to declare a variable length formal parameter (list) is: dataType... identifier.
Java for Beginners University Greenwich Computing At School DASCO
ARRAYS (Extra slides) Arrays are objects that help us organize large amounts of information.
Arrays Chapter 7.
Pseudocode Key Revision Points.
Java for Beginners University Greenwich Computing At School DASCO
IGCSE 4 Cambridge Data types and arrays Computer Science Section 2
Java for Beginners University Greenwich Computing At School DASCO
Data Structures I (CPCS-204)
Two-Dimensional Arrays
Two-Dimensional Arrays
Computer Programming BCT 1113
Microsoft Visual Basic 2005: Reloaded Second Edition
Two Dimensional Array Mr. Jacobs.
Java for Beginners University Greenwich Computing At School DASCO
Chapter 7 Part 1 Edited by JJ Shepherd
[Array, Array, Array, Array]
Java for Beginners.
Chapter 8 Arrays Objectives
User-Defined Functions
CSS161: Fundamentals of Computing
Arrays An Array is an ordered collection of variables
Java for Beginners University Greenwich Computing At School DASCO
Python I/O.
Java for Beginners University Greenwich Computing At School DASCO
Java for Teachers Intermediate
Nested Loop Review and Two-Dimensional Arrays
Chapter 8 Arrays Objectives
© A+ Computer Science - Arrays and Lists © A+ Computer Science -
Review of Arrays and Pointers
Lecture 9 Objectives Learn about arrays.
Can we solve this problem?
Topics discussed in this section:
[Array, Array, Array, Array]
Vlookup.
Data Structures (CS212D) Week # 2: Arrays.
Arrays Chapter 7.
Two-Dimensional Arrays
Multidimensional array
Arrays Week 2.
Building Java Programs
Multi-Dimensional Arrays
Java for Beginners University Greenwich Computing At School DASCO
Arrays Part 2.
Chapter 8 Arrays Objectives
Can we solve this problem?
Arrays 2-May-19.
Why are arrays useful? We can use arrays to store a large amount of data without declaring many variables. Example: Read in a file of 1000 numbers, then.
Can we solve this problem?
Java Coding 6 David Davenport Computer Eng. Dept.,
Week 7 - Monday CS 121.
Presentation transcript:

Java for Beginners Level 6 University Greenwich Computing At School DASCO Chris Coetzee

Levels of Java coding 1: Syntax, laws, variables, output 2: Input, calculations, String manipulation 3: Selection (IF-ELSE) 4: Iteration/Loops (FOR/WHILE) 5: Complex algorithms 6: Arrays/Linked Lists 7: File management 8: Methods 9: Objects and classes 10: Graphical user interface elements

Arrays vs Variables

Initialising an array

What could go wrong? num [ 0 ] always OK num [ 9 ] OK  (given the above declaration) num [ 10 ] illegal (no such cell from this declaration) num [ -1 ] always NO! (illegal) num [ 3.5 ]

Array length When dealing with arrays, it is advantageous to know the number of elements contained within the array, or the array's "length".  This length can be obtained by using the array name followed by .length.  If an array named numbers contains 10 values, the code numbers.length will be 10.  ** You must remember that the length of an array is the number of elements in the array, which is one more than the largest subscript. http://mathbits.com/MathBits/Java/arrays/Declare.htm

Parallel arrays

Parallel array applications

Parallel arrays in Java for(int index = 0; index < dogname.length; index++) {      System.out.println(dogname[index]);      System.out.println(round1[index]);      System.out.println(round2[index]); }

Searching an array using a flag

Sorting an array (Bubble Sort)

2D arrays

Declaring a 2D array in Java int[ ][ ] arrNumbers = new int[6][5]; 6 = number of rows (DOWN) 5 = number of columns (ACROSS)

Instantiating a 2D array

Example: Fill a 2D array with “X” Nothing! You only put data in, not printed it! Output

Common mistake: printing a 2D array You can’t just print the array name, You have to print every element in the array separately! Output

Correct way: printing a 2D array Output

Common 2D array tasks