SlideShare ist ein Scribd-Unternehmen logo
1 von 1
According to Budimlic et al. (2007), "every array is a Java object". However, at a more
basic level of understanding; an array is merely a container for holding a fixed number
of objects all of the same primitive type (int, byte, short, etc.). With Java, like most other
languages, once the array is created its number is fixed. Each piece of data in the array
is called an element, and the numbering process (indexing) starts at "0". Thus, your
fourth element would be indexed as "3".

To create an array within Java, you must construct the array and specify its length, or
total number of elements in the array, with an = new constructor statement. Without the
"new" constructor, the array will not be properly created and will likely cause errors upon
attempting to be compiled. Other than the array's length, you must also declare its data
type, and its identifier (name).

int[] score = new int[30];

Here you can see an array that would be used to calculate the average score on tests in
a class that has 30 students, where the new constructor makes it possible for it to be
created and all declared on one single line.

Weitere ähnliche Inhalte

Was ist angesagt?

Lecture19 unionsin c.ppt
Lecture19 unionsin c.pptLecture19 unionsin c.ppt
Lecture19 unionsin c.ppteShikshak
 
When to use a structure vs classes in c++
When to use a structure vs classes in c++When to use a structure vs classes in c++
When to use a structure vs classes in c++Naman Kumar
 
Ii pu cs practical viva voce questions
Ii pu cs  practical viva voce questionsIi pu cs  practical viva voce questions
Ii pu cs practical viva voce questionsProf. Dr. K. Adisesha
 
Dynamic memory allocation and linked lists
Dynamic memory allocation and linked listsDynamic memory allocation and linked lists
Dynamic memory allocation and linked listsDeepam Aggarwal
 
Abstract data types
Abstract data typesAbstract data types
Abstract data typesHoang Nguyen
 
Structure in c language
Structure in c languageStructure in c language
Structure in c languagesangrampatil81
 
C programing -Structure
C programing -StructureC programing -Structure
C programing -Structureshaibal sharif
 
Mca ii dfs u-1 introduction to data structure
Mca ii dfs u-1 introduction to data structureMca ii dfs u-1 introduction to data structure
Mca ii dfs u-1 introduction to data structureRai University
 
Data Types - Premetive and Non Premetive
Data Types - Premetive and Non Premetive Data Types - Premetive and Non Premetive
Data Types - Premetive and Non Premetive Raj Naik
 
Introduction to Data Structure : Pointer
Introduction to Data Structure : PointerIntroduction to Data Structure : Pointer
Introduction to Data Structure : PointerS P Sajjan
 
Cso gaddis java_chapter6
Cso gaddis java_chapter6Cso gaddis java_chapter6
Cso gaddis java_chapter6RhettB
 
Data Structure & Algorithms | Computer Science
Data Structure & Algorithms | Computer ScienceData Structure & Algorithms | Computer Science
Data Structure & Algorithms | Computer ScienceTransweb Global Inc
 
Encapsulation of operations, methods & persistence
Encapsulation of operations, methods & persistenceEncapsulation of operations, methods & persistence
Encapsulation of operations, methods & persistencePrem Lamsal
 

Was ist angesagt? (20)

Lecture19 unionsin c.ppt
Lecture19 unionsin c.pptLecture19 unionsin c.ppt
Lecture19 unionsin c.ppt
 
When to use a structure vs classes in c++
When to use a structure vs classes in c++When to use a structure vs classes in c++
When to use a structure vs classes in c++
 
Abstract Data Types
Abstract Data TypesAbstract Data Types
Abstract Data Types
 
Ii pu cs practical viva voce questions
Ii pu cs  practical viva voce questionsIi pu cs  practical viva voce questions
Ii pu cs practical viva voce questions
 
Algo>Abstract data type
Algo>Abstract data typeAlgo>Abstract data type
Algo>Abstract data type
 
Dynamic memory allocation and linked lists
Dynamic memory allocation and linked listsDynamic memory allocation and linked lists
Dynamic memory allocation and linked lists
 
Abstract data types
Abstract data typesAbstract data types
Abstract data types
 
Structure in c language
Structure in c languageStructure in c language
Structure in c language
 
C programing -Structure
C programing -StructureC programing -Structure
C programing -Structure
 
Mca ii dfs u-1 introduction to data structure
Mca ii dfs u-1 introduction to data structureMca ii dfs u-1 introduction to data structure
Mca ii dfs u-1 introduction to data structure
 
Data Types - Premetive and Non Premetive
Data Types - Premetive and Non Premetive Data Types - Premetive and Non Premetive
Data Types - Premetive and Non Premetive
 
Structures in c++
Structures in c++Structures in c++
Structures in c++
 
Structure in c sharp
Structure in c sharpStructure in c sharp
Structure in c sharp
 
Introduction to Data Structure : Pointer
Introduction to Data Structure : PointerIntroduction to Data Structure : Pointer
Introduction to Data Structure : Pointer
 
Cso gaddis java_chapter6
Cso gaddis java_chapter6Cso gaddis java_chapter6
Cso gaddis java_chapter6
 
Structure in c
Structure in cStructure in c
Structure in c
 
Structure in C
Structure in CStructure in C
Structure in C
 
Data Structure & Algorithms | Computer Science
Data Structure & Algorithms | Computer ScienceData Structure & Algorithms | Computer Science
Data Structure & Algorithms | Computer Science
 
Arrays
ArraysArrays
Arrays
 
Encapsulation of operations, methods & persistence
Encapsulation of operations, methods & persistenceEncapsulation of operations, methods & persistence
Encapsulation of operations, methods & persistence
 

Andere mochten auch

Desain cap kue
Desain cap kueDesain cap kue
Desain cap kuerobinhooda
 
shaikh aleem ahmed
shaikh aleem ahmedshaikh aleem ahmed
shaikh aleem ahmedindianwhc
 
Rumusan masal;ahh
Rumusan masal;ahhRumusan masal;ahh
Rumusan masal;ahhwisty yulia
 
Explore India’s natural beauty through Sky Waltz’s hot air balloon ride
Explore India’s natural beauty through Sky Waltz’s hot air balloon rideExplore India’s natural beauty through Sky Waltz’s hot air balloon ride
Explore India’s natural beauty through Sky Waltz’s hot air balloon rideSky Waltz
 
ServSafe Certification
ServSafe CertificationServSafe Certification
ServSafe CertificationMARIA SARRAFF
 
Slideshare (44)
Slideshare (44)Slideshare (44)
Slideshare (44)james122
 
Govindudu Andari Vaadele shooting stopped!
Govindudu Andari Vaadele shooting stopped!  Govindudu Andari Vaadele shooting stopped!
Govindudu Andari Vaadele shooting stopped! telugustop.com
 
Ficha nona
Ficha nonaFicha nona
Ficha nonaPreview
 

Andere mochten auch (11)

wajahat
wajahatwajahat
wajahat
 
Desain cap kue
Desain cap kueDesain cap kue
Desain cap kue
 
Uitleg creatiecirkel
Uitleg creatiecirkelUitleg creatiecirkel
Uitleg creatiecirkel
 
shaikh aleem ahmed
shaikh aleem ahmedshaikh aleem ahmed
shaikh aleem ahmed
 
Rumusan masal;ahh
Rumusan masal;ahhRumusan masal;ahh
Rumusan masal;ahh
 
Explore India’s natural beauty through Sky Waltz’s hot air balloon ride
Explore India’s natural beauty through Sky Waltz’s hot air balloon rideExplore India’s natural beauty through Sky Waltz’s hot air balloon ride
Explore India’s natural beauty through Sky Waltz’s hot air balloon ride
 
ServSafe Certification
ServSafe CertificationServSafe Certification
ServSafe Certification
 
Slideshare (44)
Slideshare (44)Slideshare (44)
Slideshare (44)
 
Govindudu Andari Vaadele shooting stopped!
Govindudu Andari Vaadele shooting stopped!  Govindudu Andari Vaadele shooting stopped!
Govindudu Andari Vaadele shooting stopped!
 
ResultPaper
ResultPaperResultPaper
ResultPaper
 
Ficha nona
Ficha nonaFicha nona
Ficha nona
 

Ähnlich wie Week 4 dq 4

Java - Strings Concepts
Java - Strings ConceptsJava - Strings Concepts
Java - Strings ConceptsVicter Paul
 
Class notes(week 4) on arrays and strings
Class notes(week 4) on arrays and stringsClass notes(week 4) on arrays and strings
Class notes(week 4) on arrays and stringsKuntal Bhowmick
 
Class notes(week 4) on arrays and strings
Class notes(week 4) on arrays and stringsClass notes(week 4) on arrays and strings
Class notes(week 4) on arrays and stringsKuntal Bhowmick
 
Unit-2.Arrays and Strings.pptx.................
Unit-2.Arrays and Strings.pptx.................Unit-2.Arrays and Strings.pptx.................
Unit-2.Arrays and Strings.pptx.................suchitrapoojari984
 
OCA Java SE 8 Exam Chapter 3 Core Java APIs
OCA Java SE 8 Exam Chapter 3 Core Java APIsOCA Java SE 8 Exam Chapter 3 Core Java APIs
OCA Java SE 8 Exam Chapter 3 Core Java APIsİbrahim Kürce
 
Data Structure In C#
Data Structure In C#Data Structure In C#
Data Structure In C#Shahzad
 
Java R20 - UNIT-3.docx
Java R20 - UNIT-3.docxJava R20 - UNIT-3.docx
Java R20 - UNIT-3.docxPamarthi Kumar
 
java I am trying to run my code but it is not letting me .pdf
java    I am trying to run my code but it is not letting me .pdfjava    I am trying to run my code but it is not letting me .pdf
java I am trying to run my code but it is not letting me .pdfadinathassociates
 
Abstract Data Types (a) Explain briefly what is meant by the ter.pdf
Abstract Data Types (a) Explain briefly what is meant by the ter.pdfAbstract Data Types (a) Explain briefly what is meant by the ter.pdf
Abstract Data Types (a) Explain briefly what is meant by the ter.pdfkarymadelaneyrenne19
 
Data structure.pptx
Data structure.pptxData structure.pptx
Data structure.pptxSajalFayyaz
 
Java: Objects and Object References
Java: Objects and Object ReferencesJava: Objects and Object References
Java: Objects and Object ReferencesTareq Hasan
 
The second programming assignment (HW4) is designed to help you ga.docx
The second programming assignment (HW4) is designed to help you ga.docxThe second programming assignment (HW4) is designed to help you ga.docx
The second programming assignment (HW4) is designed to help you ga.docxoreo10
 

Ähnlich wie Week 4 dq 4 (20)

Java - Strings Concepts
Java - Strings ConceptsJava - Strings Concepts
Java - Strings Concepts
 
Class notes(week 4) on arrays and strings
Class notes(week 4) on arrays and stringsClass notes(week 4) on arrays and strings
Class notes(week 4) on arrays and strings
 
Class notes(week 4) on arrays and strings
Class notes(week 4) on arrays and stringsClass notes(week 4) on arrays and strings
Class notes(week 4) on arrays and strings
 
Unit-2.Arrays and Strings.pptx.................
Unit-2.Arrays and Strings.pptx.................Unit-2.Arrays and Strings.pptx.................
Unit-2.Arrays and Strings.pptx.................
 
OCA Java SE 8 Exam Chapter 3 Core Java APIs
OCA Java SE 8 Exam Chapter 3 Core Java APIsOCA Java SE 8 Exam Chapter 3 Core Java APIs
OCA Java SE 8 Exam Chapter 3 Core Java APIs
 
Data Structure In C#
Data Structure In C#Data Structure In C#
Data Structure In C#
 
Java R20 - UNIT-3.docx
Java R20 - UNIT-3.docxJava R20 - UNIT-3.docx
Java R20 - UNIT-3.docx
 
Lecture 9
Lecture 9Lecture 9
Lecture 9
 
Lesson 2.1 array
Lesson 2.1   arrayLesson 2.1   array
Lesson 2.1 array
 
CH1 ARRAY (1).pptx
CH1 ARRAY (1).pptxCH1 ARRAY (1).pptx
CH1 ARRAY (1).pptx
 
Array lecture
Array lectureArray lecture
Array lecture
 
Ch2
Ch2Ch2
Ch2
 
java I am trying to run my code but it is not letting me .pdf
java    I am trying to run my code but it is not letting me .pdfjava    I am trying to run my code but it is not letting me .pdf
java I am trying to run my code but it is not letting me .pdf
 
Arrays in java.pptx
Arrays in java.pptxArrays in java.pptx
Arrays in java.pptx
 
Abstract Data Types (a) Explain briefly what is meant by the ter.pdf
Abstract Data Types (a) Explain briefly what is meant by the ter.pdfAbstract Data Types (a) Explain briefly what is meant by the ter.pdf
Abstract Data Types (a) Explain briefly what is meant by the ter.pdf
 
Data structure.pptx
Data structure.pptxData structure.pptx
Data structure.pptx
 
Oop java
Oop javaOop java
Oop java
 
Java: Objects and Object References
Java: Objects and Object ReferencesJava: Objects and Object References
Java: Objects and Object References
 
Array properties
Array propertiesArray properties
Array properties
 
The second programming assignment (HW4) is designed to help you ga.docx
The second programming assignment (HW4) is designed to help you ga.docxThe second programming assignment (HW4) is designed to help you ga.docx
The second programming assignment (HW4) is designed to help you ga.docx
 

Mehr von amaxwell2012 (9)

Week3 dq4
Week3 dq4Week3 dq4
Week3 dq4
 
Week3 dq1
Week3 dq1Week3 dq1
Week3 dq1
 
Week2 dq4
Week2 dq4Week2 dq4
Week2 dq4
 
Week2 dq3
Week2 dq3Week2 dq3
Week2 dq3
 
Week2 dq2
Week2 dq2Week2 dq2
Week2 dq2
 
Week1 dq5
Week1 dq5Week1 dq5
Week1 dq5
 
Week1 dq3
Week1 dq3Week1 dq3
Week1 dq3
 
Week1 dq2
Week1 dq2Week1 dq2
Week1 dq2
 
Week 4 dq 3
Week 4 dq 3Week 4 dq 3
Week 4 dq 3
 

Week 4 dq 4

  • 1. According to Budimlic et al. (2007), "every array is a Java object". However, at a more basic level of understanding; an array is merely a container for holding a fixed number of objects all of the same primitive type (int, byte, short, etc.). With Java, like most other languages, once the array is created its number is fixed. Each piece of data in the array is called an element, and the numbering process (indexing) starts at "0". Thus, your fourth element would be indexed as "3". To create an array within Java, you must construct the array and specify its length, or total number of elements in the array, with an = new constructor statement. Without the "new" constructor, the array will not be properly created and will likely cause errors upon attempting to be compiled. Other than the array's length, you must also declare its data type, and its identifier (name). int[] score = new int[30]; Here you can see an array that would be used to calculate the average score on tests in a class that has 30 students, where the new constructor makes it possible for it to be created and all declared on one single line.