SlideShare a Scribd company logo
JAVA
Part II
Loops in JAVA
What are loops?
Loops are used for repeated execution of a block.
There are following types of loops in Java:
• while Loop
• do…while loop
• for loop
While Loop
Syntax:
while (Boolean Expression)
{
//your code
}
e.g. Example_while.java
Do...while Loop
Syntax:
Do
{
//your code
}
while(Boolean_expression);
e.g. Example_dowhile.java
For Loop
Syntax:
For
(initialization; Boolean_expression; update)
{
//Statements
}
Initialization: The first step in execution for initializing your loop variable.
Boolean expression: Condition for evaluation. If evaluated to true, loop executes, else goes to the next
statement.
Update: After the body of the for loop executes, the flow of control jumps back up to the update statement.
This statement allows you to update any loop control variables.
The code block is re-executed till the time the Boolean expression evaluates to true.
Example: Example_for.java
Break & Continue
Break: for breaking out of the loop immediately and execute what's after the
block.
Continue: it causes the flow of control to jump to the next iteration.
Syntax:
break; // for break
continue; //for continue
Example: Example_break_continue.java
Methods
What is a Method?
9 A Java method is a collection of statements that are grouped
together to perform an operation.
Syntax:
modifier returnValueType methodName(list of parameters)
{
// Method body;
}
Example: Example_method.java
Array is a collection of variables that can hold value of
same type and reference by common name
.Its is a derived data Structure
Array are always stored in a continuous memory locations. An Array
either be a integer ,character, or float base type (Data type of array) .
Array indexing is always start from zero and highest address
corresponds to last element
Introduction
Num [0]
Num[1]
Num[2]
Num[3]
Num[4]
Num[5]
Int num [6]
Base type of
arrray
Name
of array
Size of
array
Continuous
memory
allocation of
array
To store processed large number of variables of same
data type and reference/name
Easy understanding of program
Example: Marks
0
1
2
3
4
5
Need of Arrray
One dimensional
Two dimensional
Multi dimensional
T
ypesofArray
A one dimensional array is one in which one
subscript /indices specification is needed to
specify a particular element of array
Declaration :
Data_type array_name [size of array ];
Eg:
Int num[10];
1-D Array
num[0] num[1] num[2] num[3] num[4] num[5] num[6] num[7] num[8]
num[9]
2000 2002 2004 2006 2008 2010 2012 2014 2016 2018
starting Address of location
Totalmemoryinbytesthat anarrayisoccupied:
Size of array=size of array*size of(base type)
Hear,
10*2=20
39 56 23 98 6 56 09 2 54 67
Memory representation:
A 2-d array is an array in which each element is itself
an array
i.e int num[4][3]
0 1 2
0
1
2
3
2-D Array
No of
rows
No of
columns
Num [2][1]
No of element in
2-D array =M*N
Total bytes= no of rows*no of columns*size of(base
type)
Memory reprsentation in 2-D array:
char A [2][3]
A[0][0] A[0][1] A[0][2] A[1][0] A[1][1] A[1][2]
5001 5002 5003 5004 5005 5006
size of 2-D array
An array with dimensions more than two .The
maximum limit of array is compiler dependent
Declration:
Data_type name [a][b][c][d][e][f]…….[n];
Array of 3 or more dimensional are not often
use because of huge memory requirement
and complexity involved
Multi dimensional array
C++ provides the facility of array initialization at the time of
declaration .General form of array initialization is as:
Type array_name[size 1]…..[size N] ={vale list};
Eg:
Int days_month[12]={31,25,29,03,31,19,20,31,18,20,31,29};
Char string[6]={‘a’,’r’,’g’,’y’,’d’,’0’};
2-D array are also initialized in same way as linear array
Int cube[4][2]={ 1,3,
4,6,
9,37,
5,78
};
Array initialization
Unsized array initializations
C++ allowed you to skip the size of array in an array initialization statement C++ automatically create an array big enough to hold all the
initializers present
Char S1[] =“ first string ”;
you skip the size, you must give list of initializers so that C++
can calculate the size of array
Int val []={3,5,6,2,8,9,6,4};
Int cube [] [2] ={ 1,3,
67,7,
6,87,
};
C++ does not have a String data type ,it
impairments string as 1-D character Arrray .A
string as a character array is terminate by a
null character ‘0’
Char str 1 [11];
Char square [][]={ ‘first string’,
‘second string’,
‘third string’
};
String as array
THANKS!
Dr Pankaj Gupta
Head – ACCESS Health Digital
digital.health@accessh.org
Twitter: @pankajguptadr, @accesshdigital
LinkedIn: drpankajgupta, accesshdigital

More Related Content

What's hot

Array in c++
Array in c++Array in c++
Array in c++
Mahesha Mano
 
Presentation on array
Presentation on array Presentation on array
Presentation on array
topu93
 
Array
ArrayArray
ARRAY
ARRAYARRAY
ARRAY
ayush raj
 
Array in c programming
Array in c programmingArray in c programming
Array in c programming
Mazharul Islam
 
Arrays
ArraysArrays
arrays in c
arrays in carrays in c
arrays in c
vidhi mehta
 
Array in C
Array in CArray in C
Array in C
adityas29
 
Arrays in c language
Arrays in c languageArrays in c language
Arrays in c language
tanmaymodi4
 
Arrays in c
Arrays in cArrays in c
Arrays in c
Jeeva Nanthini
 
Array Presentation
Array PresentationArray Presentation
Array Presentation
Deep Prajapati Microplacer
 
Arrays In C
Arrays In CArrays In C
Arrays In C
yndaravind
 
Array in c language
Array in c languageArray in c language
Array in c language
umesh patil
 
Arrays In C++
Arrays In C++Arrays In C++
Arrays In C++
Awais Alam
 
Array
ArrayArray
Array
Hajar
 
A Presentation About Array Manipulation(Insertion & Deletion in an array)
A Presentation About Array Manipulation(Insertion & Deletion in an array)A Presentation About Array Manipulation(Insertion & Deletion in an array)
A Presentation About Array Manipulation(Insertion & Deletion in an array)
Imdadul Himu
 
Arrays
ArraysArrays
Arrays
Faisal Aziz
 
7array in c#
7array in c#7array in c#
7array in c#
Sireesh K
 
Basic array in c programming
Basic array in c programmingBasic array in c programming
Basic array in c programming
Sajid Hasan
 
Array and Collections in c#
Array and Collections in c#Array and Collections in c#
Array and Collections in c#
Umar Farooq
 

What's hot (20)

Array in c++
Array in c++Array in c++
Array in c++
 
Presentation on array
Presentation on array Presentation on array
Presentation on array
 
Array
ArrayArray
Array
 
ARRAY
ARRAYARRAY
ARRAY
 
Array in c programming
Array in c programmingArray in c programming
Array in c programming
 
Arrays
ArraysArrays
Arrays
 
arrays in c
arrays in carrays in c
arrays in c
 
Array in C
Array in CArray in C
Array in C
 
Arrays in c language
Arrays in c languageArrays in c language
Arrays in c language
 
Arrays in c
Arrays in cArrays in c
Arrays in c
 
Array Presentation
Array PresentationArray Presentation
Array Presentation
 
Arrays In C
Arrays In CArrays In C
Arrays In C
 
Array in c language
Array in c languageArray in c language
Array in c language
 
Arrays In C++
Arrays In C++Arrays In C++
Arrays In C++
 
Array
ArrayArray
Array
 
A Presentation About Array Manipulation(Insertion & Deletion in an array)
A Presentation About Array Manipulation(Insertion & Deletion in an array)A Presentation About Array Manipulation(Insertion & Deletion in an array)
A Presentation About Array Manipulation(Insertion & Deletion in an array)
 
Arrays
ArraysArrays
Arrays
 
7array in c#
7array in c#7array in c#
7array in c#
 
Basic array in c programming
Basic array in c programmingBasic array in c programming
Basic array in c programming
 
Array and Collections in c#
Array and Collections in c#Array and Collections in c#
Array and Collections in c#
 

Similar to Java part 2

Arrays
ArraysArrays
Arrays
ArraysArrays
Programming in c Arrays
Programming in c ArraysProgramming in c Arrays
Programming in c Arrays
janani thirupathi
 
Array and its types and it's implemented programming Final.pdf
Array and its types and it's implemented programming Final.pdfArray and its types and it's implemented programming Final.pdf
Array and its types and it's implemented programming Final.pdf
ajajkhan16
 
Visual Programing basic lectures 7.pptx
Visual Programing basic lectures  7.pptxVisual Programing basic lectures  7.pptx
Visual Programing basic lectures 7.pptx
Mrhaider4
 
Array.pptx
Array.pptxArray.pptx
Array.pptx
fixocin377
 
Ch5 array nota
Ch5 array notaCh5 array nota
Ch5 array nota
Hattori Sidek
 
Ch08
Ch08Ch08
Chapter 4 (Part I) - Array and Strings.pdf
Chapter 4 (Part I) - Array and Strings.pdfChapter 4 (Part I) - Array and Strings.pdf
Chapter 4 (Part I) - Array and Strings.pdf
KirubelWondwoson1
 
C programming session 04
C programming session 04C programming session 04
C programming session 04
Dushmanta Nath
 
6 arrays injava
6 arrays injava6 arrays injava
6 arrays injava
irdginfo
 
Identifiers, keywords and types
Identifiers, keywords and typesIdentifiers, keywords and types
Identifiers, keywords and types
Daman Toor
 
C++ lecture 04
C++ lecture 04C++ lecture 04
C++ lecture 04
HNDE Labuduwa Galle
 
Functions, Strings ,Storage classes in C
 Functions, Strings ,Storage classes in C Functions, Strings ,Storage classes in C
Functions, Strings ,Storage classes in C
arshpreetkaur07
 
JAVA LESSON-01.pptx
JAVA LESSON-01.pptxJAVA LESSON-01.pptx
JAVA LESSON-01.pptx
StephenOczon1
 
Lecture_01.2.pptx
Lecture_01.2.pptxLecture_01.2.pptx
Lecture_01.2.pptx
RockyIslam5
 
Unit4 Slides
Unit4 SlidesUnit4 Slides
Unit4 Slides
Rakesh Roshan
 
Intake 38 3
Intake 38 3Intake 38 3
Intake 38 3
Mahmoud Ouf
 
Java R20 - UNIT-3.docx
Java R20 - UNIT-3.docxJava R20 - UNIT-3.docx
Java R20 - UNIT-3.docx
Pamarthi Kumar
 
Introduction to System verilog
Introduction to System verilog Introduction to System verilog
Introduction to System verilog
Pushpa Yakkala
 

Similar to Java part 2 (20)

Arrays
ArraysArrays
Arrays
 
Arrays
ArraysArrays
Arrays
 
Programming in c Arrays
Programming in c ArraysProgramming in c Arrays
Programming in c Arrays
 
Array and its types and it's implemented programming Final.pdf
Array and its types and it's implemented programming Final.pdfArray and its types and it's implemented programming Final.pdf
Array and its types and it's implemented programming Final.pdf
 
Visual Programing basic lectures 7.pptx
Visual Programing basic lectures  7.pptxVisual Programing basic lectures  7.pptx
Visual Programing basic lectures 7.pptx
 
Array.pptx
Array.pptxArray.pptx
Array.pptx
 
Ch5 array nota
Ch5 array notaCh5 array nota
Ch5 array nota
 
Ch08
Ch08Ch08
Ch08
 
Chapter 4 (Part I) - Array and Strings.pdf
Chapter 4 (Part I) - Array and Strings.pdfChapter 4 (Part I) - Array and Strings.pdf
Chapter 4 (Part I) - Array and Strings.pdf
 
C programming session 04
C programming session 04C programming session 04
C programming session 04
 
6 arrays injava
6 arrays injava6 arrays injava
6 arrays injava
 
Identifiers, keywords and types
Identifiers, keywords and typesIdentifiers, keywords and types
Identifiers, keywords and types
 
C++ lecture 04
C++ lecture 04C++ lecture 04
C++ lecture 04
 
Functions, Strings ,Storage classes in C
 Functions, Strings ,Storage classes in C Functions, Strings ,Storage classes in C
Functions, Strings ,Storage classes in C
 
JAVA LESSON-01.pptx
JAVA LESSON-01.pptxJAVA LESSON-01.pptx
JAVA LESSON-01.pptx
 
Lecture_01.2.pptx
Lecture_01.2.pptxLecture_01.2.pptx
Lecture_01.2.pptx
 
Unit4 Slides
Unit4 SlidesUnit4 Slides
Unit4 Slides
 
Intake 38 3
Intake 38 3Intake 38 3
Intake 38 3
 
Java R20 - UNIT-3.docx
Java R20 - UNIT-3.docxJava R20 - UNIT-3.docx
Java R20 - UNIT-3.docx
 
Introduction to System verilog
Introduction to System verilog Introduction to System verilog
Introduction to System verilog
 

More from ACCESS Health Digital

Governance healthcare financial lever
Governance healthcare financial lever Governance healthcare financial lever
Governance healthcare financial lever
ACCESS Health Digital
 
Startup bootcamp 3
Startup bootcamp 3Startup bootcamp 3
Startup bootcamp 3
ACCESS Health Digital
 
Startup bootcamp 2
Startup bootcamp 2Startup bootcamp 2
Startup bootcamp 2
ACCESS Health Digital
 
Oops concepts
Oops conceptsOops concepts
Oops concepts
ACCESS Health Digital
 
Microservices
MicroservicesMicroservices
Microservices
ACCESS Health Digital
 
Java part 3
Java part  3Java part  3
Java part 1
Java part 1Java part 1
Hl7 & FHIR
Hl7 & FHIRHl7 & FHIR
Federated architecture
Federated architectureFederated architecture
Federated architecture
ACCESS Health Digital
 
E objects implementation
E objects implementationE objects implementation
E objects implementation
ACCESS Health Digital
 
Design patterns
Design patternsDesign patterns
Design patterns
ACCESS Health Digital
 
Database concepts
Database conceptsDatabase concepts
Database concepts
ACCESS Health Digital
 
Computer networks
Computer networksComputer networks
Computer networks
ACCESS Health Digital
 
Cloud computing
Cloud computingCloud computing
Cloud computing
ACCESS Health Digital
 
MDDS & NDHB Principles
MDDS & NDHB PrinciplesMDDS & NDHB Principles
MDDS & NDHB Principles
ACCESS Health Digital
 
Health information exchange (HIE)
Health information exchange (HIE)Health information exchange (HIE)
Health information exchange (HIE)
ACCESS Health Digital
 
Health insurance information platform (hiip)
Health insurance information platform (hiip)Health insurance information platform (hiip)
Health insurance information platform (hiip)
ACCESS Health Digital
 
Closed loop medication administration
Closed loop medication administrationClosed loop medication administration
Closed loop medication administration
ACCESS Health Digital
 
Health delivery information system [HDIS] MVP
Health delivery information system [HDIS] MVPHealth delivery information system [HDIS] MVP
Health delivery information system [HDIS] MVP
ACCESS Health Digital
 
HCIT is different
HCIT is differentHCIT is different
HCIT is different
ACCESS Health Digital
 

More from ACCESS Health Digital (20)

Governance healthcare financial lever
Governance healthcare financial lever Governance healthcare financial lever
Governance healthcare financial lever
 
Startup bootcamp 3
Startup bootcamp 3Startup bootcamp 3
Startup bootcamp 3
 
Startup bootcamp 2
Startup bootcamp 2Startup bootcamp 2
Startup bootcamp 2
 
Oops concepts
Oops conceptsOops concepts
Oops concepts
 
Microservices
MicroservicesMicroservices
Microservices
 
Java part 3
Java part  3Java part  3
Java part 3
 
Java part 1
Java part 1Java part 1
Java part 1
 
Hl7 & FHIR
Hl7 & FHIRHl7 & FHIR
Hl7 & FHIR
 
Federated architecture
Federated architectureFederated architecture
Federated architecture
 
E objects implementation
E objects implementationE objects implementation
E objects implementation
 
Design patterns
Design patternsDesign patterns
Design patterns
 
Database concepts
Database conceptsDatabase concepts
Database concepts
 
Computer networks
Computer networksComputer networks
Computer networks
 
Cloud computing
Cloud computingCloud computing
Cloud computing
 
MDDS & NDHB Principles
MDDS & NDHB PrinciplesMDDS & NDHB Principles
MDDS & NDHB Principles
 
Health information exchange (HIE)
Health information exchange (HIE)Health information exchange (HIE)
Health information exchange (HIE)
 
Health insurance information platform (hiip)
Health insurance information platform (hiip)Health insurance information platform (hiip)
Health insurance information platform (hiip)
 
Closed loop medication administration
Closed loop medication administrationClosed loop medication administration
Closed loop medication administration
 
Health delivery information system [HDIS] MVP
Health delivery information system [HDIS] MVPHealth delivery information system [HDIS] MVP
Health delivery information system [HDIS] MVP
 
HCIT is different
HCIT is differentHCIT is different
HCIT is different
 

Recently uploaded

Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
Zilliz
 
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying AheadDigital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Wask
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
Hiroshi SHIBATA
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
kumardaparthi1024
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
alexjohnson7307
 
WeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation TechniquesWeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation Techniques
Postman
 
Operating System Used by Users in day-to-day life.pptx
Operating System Used by Users in day-to-day life.pptxOperating System Used by Users in day-to-day life.pptx
Operating System Used by Users in day-to-day life.pptx
Pravash Chandra Das
 
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Jeffrey Haguewood
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
Jason Packer
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
Nunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdf
Nunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdfNunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdf
Nunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdf
flufftailshop
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
Chart Kalyan
 
Recommendation System using RAG Architecture
Recommendation System using RAG ArchitectureRecommendation System using RAG Architecture
Recommendation System using RAG Architecture
fredae14
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
panagenda
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
shyamraj55
 
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - HiikeSystem Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
Hiike
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
Jakub Marek
 
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptxOcean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
SitimaJohn
 

Recently uploaded (20)

Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
 
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying AheadDigital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying Ahead
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
 
WeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation TechniquesWeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation Techniques
 
Operating System Used by Users in day-to-day life.pptx
Operating System Used by Users in day-to-day life.pptxOperating System Used by Users in day-to-day life.pptx
Operating System Used by Users in day-to-day life.pptx
 
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
Nunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdf
Nunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdfNunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdf
Nunit vs XUnit vs MSTest Differences Between These Unit Testing Frameworks.pdf
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
 
Recommendation System using RAG Architecture
Recommendation System using RAG ArchitectureRecommendation System using RAG Architecture
Recommendation System using RAG Architecture
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
 
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - HiikeSystem Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
 
Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
 
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptxOcean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
 

Java part 2

  • 2. Loops in JAVA What are loops? Loops are used for repeated execution of a block. There are following types of loops in Java: • while Loop • do…while loop • for loop
  • 3. While Loop Syntax: while (Boolean Expression) { //your code } e.g. Example_while.java
  • 5. For Loop Syntax: For (initialization; Boolean_expression; update) { //Statements } Initialization: The first step in execution for initializing your loop variable. Boolean expression: Condition for evaluation. If evaluated to true, loop executes, else goes to the next statement. Update: After the body of the for loop executes, the flow of control jumps back up to the update statement. This statement allows you to update any loop control variables. The code block is re-executed till the time the Boolean expression evaluates to true. Example: Example_for.java
  • 6. Break & Continue Break: for breaking out of the loop immediately and execute what's after the block. Continue: it causes the flow of control to jump to the next iteration. Syntax: break; // for break continue; //for continue Example: Example_break_continue.java
  • 8. What is a Method? 9 A Java method is a collection of statements that are grouped together to perform an operation. Syntax: modifier returnValueType methodName(list of parameters) { // Method body; } Example: Example_method.java
  • 9. Array is a collection of variables that can hold value of same type and reference by common name .Its is a derived data Structure Array are always stored in a continuous memory locations. An Array either be a integer ,character, or float base type (Data type of array) . Array indexing is always start from zero and highest address corresponds to last element Introduction
  • 10. Num [0] Num[1] Num[2] Num[3] Num[4] Num[5] Int num [6] Base type of arrray Name of array Size of array Continuous memory allocation of array
  • 11. To store processed large number of variables of same data type and reference/name Easy understanding of program Example: Marks 0 1 2 3 4 5 Need of Arrray
  • 13. A one dimensional array is one in which one subscript /indices specification is needed to specify a particular element of array Declaration : Data_type array_name [size of array ]; Eg: Int num[10]; 1-D Array
  • 14. num[0] num[1] num[2] num[3] num[4] num[5] num[6] num[7] num[8] num[9] 2000 2002 2004 2006 2008 2010 2012 2014 2016 2018 starting Address of location Totalmemoryinbytesthat anarrayisoccupied: Size of array=size of array*size of(base type) Hear, 10*2=20 39 56 23 98 6 56 09 2 54 67 Memory representation:
  • 15. A 2-d array is an array in which each element is itself an array i.e int num[4][3] 0 1 2 0 1 2 3 2-D Array No of rows No of columns Num [2][1] No of element in 2-D array =M*N
  • 16. Total bytes= no of rows*no of columns*size of(base type) Memory reprsentation in 2-D array: char A [2][3] A[0][0] A[0][1] A[0][2] A[1][0] A[1][1] A[1][2] 5001 5002 5003 5004 5005 5006 size of 2-D array
  • 17. An array with dimensions more than two .The maximum limit of array is compiler dependent Declration: Data_type name [a][b][c][d][e][f]…….[n]; Array of 3 or more dimensional are not often use because of huge memory requirement and complexity involved Multi dimensional array
  • 18. C++ provides the facility of array initialization at the time of declaration .General form of array initialization is as: Type array_name[size 1]…..[size N] ={vale list}; Eg: Int days_month[12]={31,25,29,03,31,19,20,31,18,20,31,29}; Char string[6]={‘a’,’r’,’g’,’y’,’d’,’0’}; 2-D array are also initialized in same way as linear array Int cube[4][2]={ 1,3, 4,6, 9,37, 5,78 }; Array initialization
  • 19. Unsized array initializations C++ allowed you to skip the size of array in an array initialization statement C++ automatically create an array big enough to hold all the initializers present Char S1[] =“ first string ”; you skip the size, you must give list of initializers so that C++ can calculate the size of array Int val []={3,5,6,2,8,9,6,4}; Int cube [] [2] ={ 1,3, 67,7, 6,87, };
  • 20. C++ does not have a String data type ,it impairments string as 1-D character Arrray .A string as a character array is terminate by a null character ‘0’ Char str 1 [11]; Char square [][]={ ‘first string’, ‘second string’, ‘third string’ }; String as array
  • 21. THANKS! Dr Pankaj Gupta Head – ACCESS Health Digital digital.health@accessh.org Twitter: @pankajguptadr, @accesshdigital LinkedIn: drpankajgupta, accesshdigital