1. Penulisan array yang benar adalah : double[] myList; myList = new double[10];  Array with myList has variable dimension 10  Index begin from 0 till.

Slides:



Advertisements
Similar presentations
AP Computer Science Anthony Keen. Computer 101 What happens when you turn a computer on? –BIOS tries to start a system loader –A system loader tries to.
Advertisements

1 Arrays, Strings and Collections [2] Rajkumar Buyya Grid Computing and Distributed Systems (GRIDS) Laboratory Dept. of Computer Science and Software Engineering.
Introduction to Java 2 Programming Lecture 5 Array and Collections.
Copyright © 2003 Pearson Education, Inc. Slide 1.
Copyright © 2002 Pearson Education, Inc. Slide 1.
Chapter 9 – One-Dimensional Numeric Arrays. Array u Data structure u Grouping of like-type data u Indicated with brackets containing positive integer.
Etter/Ingber Arrays and Matrices. Etter/Ingber One-Dimensional Arrays 4 An array is an indexed data structure 4 All variables stored in an array are of.
Introduction to arrays Array One dimenstional array.
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 3: Flow Control I: For Loops.
Introduction to Programming
Chapter 8: Arrays.
1.A computer game is an example of A.system software; B.a compiler; C.application software; D.hardware; E.none of the above. 2.JVM stands for: A.Java Virtual.
STRING AN EXAMPLE OF REFERENCE DATA TYPE. 2 Primitive Data Types  The eight Java primitive data types are:  byte  short  int  long  float  double.
CS 141 Computer Programming 1 1 Arrays. Outline  Introduction  Arrays  Declaring Arrays  Examples Using Arrays  Sorting Arrays  Multiple-Subscripted.
EC-111 Algorithms & Computing Lecture #7 Instructor: Jahan Zeb Department of Computer Engineering (DCE) College of E&ME NUST.
Chapter 5 Arrays F Introducing Arrays F Declaring Array Variables, Creating Arrays, and Initializing Arrays F Passing Arrays to Methods F Copying Arrays.
Introduction to Arrays Chapter What is an array? An array is an ordered collection that stores many elements of the same type within one variable.
Computer Programming Lab(7).
SORTING Matakuliah: T0974 / Algoritma dan Metode Object Oriented Programming I Tahun: 2008 Versi: 1/0.
Introduction to Programming Lecture 15. In Today’s Lecture Pointers and Arrays Manipulations Pointers and Arrays Manipulations Pointers Expression Pointers.
An Array A sequence of elements of a particular type Each element in the array has an index which gives its position in the sequence An array is declared.
Arrays. What is an array An array is used to store a collection of data It is a collection of variables of the same type.
Introduction to Application Programming IST 256 Application Programming for Information Systems Xiaozhong Liu
Arrays Liang, Chpt 5. arrays Fintan Array of chars For example, a String variable contains an array of characters: An array is a data structure.
Numbers and Arrays. Widening and narrowing Numeric types are arranged in a continuum: double float long int short byte, char You can easily assign a narrower.
CMPUT 101 Lab #6 October 29, :00 – 17:00. Array in C/C++ Array is a structure type variable. One dimension of array int: int num[3]; There are.
©2004 Brooks/Cole Chapter 8 Arrays. Figures ©2004 Brooks/Cole CS 119: Intro to JavaFall 2005 Sometimes we have lists of data values that all need to be.
© The McGraw-Hill Companies, 2006 Chapter 5 Arrays.
Chapter 5 Arrays F Introducing Arrays F Declaring Array Variables, Creating Arrays, and Initializing Arrays F Passing Arrays to Methods F Copying Arrays.
ARRAYS In this Lecture, we will try to develop understanding of some of the relatively complex concepts. The following are explained in this lecture with.
COMPUTER SCIENCE FEBRUARY 2011 Lists in Python. Introduction to Lists Lists (aka arrays): an ordered set of elements  A compound data type, like strings.
 For Loops › for (variable set; condition; incremental or decrement){ // loop beginning › } // loop end  While loops › while (condition) { // beginning.
Arrays and Strings Introducing Arrays Declaring Arrays Creating Arrays Initializing Arrays Array of Objects Copying Arrays Multidimensional Arrays Command-Line.
Introduction to Arrays in Java Corresponds with Chapter 6 of textbook.
Java Arrays [Lists] in 10 Minutes. Declaring an array (and its types) int[] myIntArray; double[] myDoubleArray; String[] myStrings; //What’s the pattern?
Java Arrays …………. Java Arrays …………. * arrays are objects in Java * arrays are objects in Java * an array variable is a reference * an array variable is.
Computer Science 210 Computer Organization Arrays.
Chapter 8: Collections: Arrays. 2 Objectives One-Dimensional Arrays Array Initialization The Arrays Class: Searching and Sorting Arrays as Arguments The.
Arrays Chapter 8. What if we need to store test scores for all students in our class. We could store each test score as a unique variable: int score1.
CHAPTER 7 arrays I NTRODUCTION T O C OMPUTER P ROGRAMMING (CSC425)
Two –Dimensional Arrays Mrs. C. Furman September 18, 2008.
Enhanced For Loops (For Each Loops) Less Code and Less Overhead for Writing For Loops.
Array, Structure and Union
Python Arrays. An array is a variable that stores a collection of things, like a list. For example a list of peoples names. We can access the different.
***** SWTJC STEM ***** Chapter 7 cg 68 What Are Arrays? An array is a simple but powerful way to organize and store large amounts of data and information.
 Structures are like arrays except that they allow many variables of different types grouped together under the same name. For example you can create.
C Programming – Part 3 Arrays and Strings.  Collection of variables of the same type  Individual array elements are identified by an integer index 
CSE 232: C++ memory management Overview of Arrays Arrays are the simplest kind of data structure –One item right after another in memory (“contiguous range”
Arrays. Related data items Collection of the same types of data. Static entity – Same size throughout program.
CS 139-Programming Fundamentals Lecture 11B - Arrays Adapted from a presentation by Dr. Rahman Fall 2014.
Authors: Peter Cappello Damon Chastain Matthew Urtnowski Course:CECS 541 Instructor: Dr. Michael Hoffman Date:Fall 2010.
Lab 8. Declaring and Creating Arrays in One Step datatype[] arrayRefVar = new datatype[arraySize]; double[] myList = new double[10];
Arrays. The array data structure Array is a collection of elements, that have the same data type Integers (int) Floating point numbers (float, double)
Get Longest Run Index (FR) public int getLongestRunIndex(int []values) { int maxRunStart = -1, maxRunLength = 1; int runStart = 0, runLength = 1; for(int.
Lec 13 Oct 21, 02. Array Initialization in the declaration statement ► int temp[5] = {98, 87, 92, 79,85}; ► char codes[6] = { ‘s’, ’a’, ‘m’, ‘p’, ‘l’,
Strings, Characters, and Regular Expressions Session 10 Mata kuliah: M0874 – Programming II Tahun: 2010.
 Introducing Arrays  Declaring Array Variables, Creating Arrays, and Initializing Arrays  Copying Arrays  Multidimensional Arrays  Search and Sorting.
© 2006 Pearson Addison-Wesley. All rights reserved Arrays of Greater Dimension One-dimensional arrays are linear containers. Multi-dimensional Arrays.
Arrays F Introducing Arrays F Declaring Array Variables F Creating Arrays, and Initializing Arrays F Copying Arrays F Multidimensional Arrays.
Liang, Introduction to Java Programming, Fifth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 6 Arrays.
1 st Semester Module 7 Arrays อภิรักษ์ จันทร์สร้าง Aphirak Jansang Computer Engineering Department.
Computer Programming Arrays 1. Question #1 2 Question Choose the correct answer..
Arrays. What is an array? An array is a collection of data types. For example, what if I wanted to 10 different integers? int num1; int num2; int num3;
Introduction to programming in java Lecture 21 Arrays – Part 1.
CSE 1301 Lecture 12 Arrays Figures from Lewis, “C# Software Solutions”, Addison Wesley Richard Gesick.
Foundations of Programming: Arrays
Register Use Policy Conventions
Lists in Python.
12.4 p 471 a) double[] number = {1.05, 2.05, 3.05, 4.05, 5.05};
INC 161 , CPE 100 Computer Programming
Presentation transcript:

1. Penulisan array yang benar adalah : double[] myList; myList = new double[10];  Array with myList has variable dimension 10  Index begin from 0 till 9  Value at array dimension > 0  Begin from 0 till n-1  Value at […] be in in the form of integer variable.

 To know length of array can use array. length Example: Array 1 dimension: int [] bilangan = new int[10]; System.out.println(“length of array 1 dimension: "+bilangan.length);

Bina Nusantara  Example of array data char type: char[] city = {‘D’,’a’,’l’,’l’,’a’,’s’}; to print: System.out.println(city);  Example array for String: String[] name={"Andre", "Bunga", "Christine", "Dedianto"}; To print name index-0  System.out.println(name[0]); To print name index-1  System.out.println(name[1]);

 Easy to duplicate easy int[] sourceArray = new int[10]; int[] targetArray = new int[sourceArray.length];  Easy to looping for( int i = 0 ; i < sourceArray.length ; i++ ) targetArray[i] = sourceArray[i];

Bina Nusantara for(int i=1; i<=3; i++) { for(int j=1; j<=3; j++) { if(j==2) break; System.out.println("i="+i+" dan j="+j); }  At j==2, execution exit from inner looping  Value j==2, and j==3 not printed  Looping continued at i++

Bina Nusantara

for(int i=1; i<=3; i++) { for(int j=1; j<=3; j++) { if(j==2) continue; System.out.println("i="+i+" dan j="+j); } At j==2, execution not exit from looping Following statement be ignored Value j==2 (following statement) not printed in j++ Value j==3 (following statement) printed

Bina Nusantara

 Statements that can cause exception are in scope try  Exception catch are in scope catch  Statement that in scope catch is a operation that done if exception occurred  Exception catch at catch Exception e)  After catch, then program will be back to normal.  The next Statement will be running normal

Bina Nusantara Method Declaration public static int max(int num1, int num2) { int result; if(num1>num2) result = num1; else result = num2; return result; } int z = max(x, y); modifier return value method name formal parameter method header parameter list method body return value Calling of method actual parameters (arguments)

Bina Nusantara Bubble Sort Adjacent value compared If increasing, then change to become decreasing

Search for the biggest value put at the end of array

 Import Declaration import java.util.Random;  Random Initialization Random r = new Random();  Using of random number int i = r.nextInt(int n)  int >= 0 and < n. int i = r.nextInt()  int (full range). long l = r.nextLong()  long (full range). float f = r.nextFloat()  float >=0.0 dan < 1.0. boolean b = r.nextBoolean()  boolean (true atau false). double d = r.nextGaussian()  double mean 0.0 dan standar deviasi 1.0.

 pausing execution for certain time  Useful for simple animation  Syntax: try { Thread.sleep(milliseconds); } catch(Exception e) { }  1 second = 1000 milliseconds

 For multiple choice, read theories and examples from BINUSMAYA  For essay, Please try to make programs for : - 2 dimension array and read data for arrays - Declaring method and calling it - Bubble and selection sort