SlideShare a Scribd company logo
5
Most read
6
Most read
7
Most read
Array In Java
Created by
Manish Tiwari
Presentation By
Manish Tiwari,
Assistant Professor,
Software Engineer,
Computer Science and Application
2. WhatsApp: ?
4. Blog: manishtiwarise.blogspot.in
3. Email: tiwarikmanish@gmail.com
1. Twitter: @manishtiwarise
5. SlideShare:
https://www.slideshare.net/tiwarikmanish
Find Notes
A R R A Y S
0 1 2 3 4 5
Element
Index
Array is a collection of similar type(Homogeneous) of elements
stored in contiguous memory location.
Definition of Java Array
1. Code Optimization: It makes the code optimized, we can
retrieve or sort the data easily.
2. Random access: We can get any data located at any index
position.
Advantage of Java Array
1. Size Limit: We can store only fixed size of elements in the
array. It doesn't grow its size at runtime. To solve this problem,
collection framework is used in java.
Disadvantage of Java Array
1. Single Dimensional Array
Syntax:
// preferred way.
1. DataType[] ArrayName;
Example: double[] myList;
2. DataType ArrayName[];
Example: double myList[];
Types of Java Array
2. Multidimensional Array
Syntax:
// preferred way.
1. dataType[][] arrayRefVar; (or)
2. dataType [][]arrayRefVar; (or)
3. dataType arrayRefVar[][]; (or)
4. dataType []arrayRefVar[]; 0
There are Two Types of Array.
class Testarray
{
public static void main(String args[])
{
int a[]=new int[5];//declaration and instantiation
a[0]=10;//initialization
a[1]=20;
a[2]=70;
a[3]=40;
a[4]=50;
//printing array
for(int i=0;i<a.length;i++)//length is the property of array
System.out.println(a[i]);
}
}
Program-Single Dimensional Array
class Testarray1
{
public static void main(String args[])
{
int a[]={33,3,4,5};
//declaration, instantiation and initialization
//printing array
for(int i=0;i<a.length;i++)
//length is the property of array
System.out.println(a[i]);
}
}
Declaration, Instantiation and Initialization of Java Array
class Testarray5
{
public static void main(String args[]){
int a[][]={{1,3,4},{3,4,5}};
int b[][]={{1,3,4},{3,4,5}};
int c[][]=new int[2][3];
for(int i=0;i<2;i++)
{
for(int j=0;j<3;j++)
{
c[i][j]=a[i][j]+b[i][j];
System.out.print(c[i][j]+" ");
}
System.out.println();//new line
}
}
}
Adding 2 Matrices Using Multi Dimensional
String is a sequence of characters. But in java, string is an object
that represents a sequence of characters. The java.lang.String
class is used to create string object.
String in Java
String Types
There are two ways to create String object:
1.By string literal
String s="welcome";
2. By new keyword
String s=new String("Welcome");
String Program
public class StringExample
{
public static void main(String args[])
{
String s1="java";
char ch[]={'s','t','r','i','n','g','s'};
String s2=new String(ch);
String s3=new String("example");
System.out.println(s1);
System.out.println(s2);
System.out.println(s3);
System.out.println(s1.toUpperCase());
System.out.println(s1.toLowerCase());
System.out.println(s2.charAt(3));
System.out.println(s2.length());
System.out.println(s3.trim());
System.out.println(s3.startsWith(“s"));//true
System.out.println(s1.endsWith(“s"));//true
}
}

More Related Content

PPTX
Programming in c Arrays
janani thirupathi
 
PPTX
Arrays
Trupti Agrawal
 
PPTX
Strings in Java
Abhilash Nair
 
PPTX
Exception Handling in Java
lalithambiga kamaraj
 
PPTX
Pointers in c++
Vineeta Garg
 
PPSX
Data Types & Variables in JAVA
Ankita Totala
 
PPT
Strings
Mitali Chugh
 
PPTX
Control statements in c
Sathish Narayanan
 
Programming in c Arrays
janani thirupathi
 
Strings in Java
Abhilash Nair
 
Exception Handling in Java
lalithambiga kamaraj
 
Pointers in c++
Vineeta Garg
 
Data Types & Variables in JAVA
Ankita Totala
 
Strings
Mitali Chugh
 
Control statements in c
Sathish Narayanan
 

What's hot (20)

PDF
ITFT-Constants, variables and data types in java
Atul Sehdev
 
PPTX
JAVA AWT
shanmuga rajan
 
PPS
Java Exception handling
kamal kotecha
 
PPTX
Java abstract class & abstract methods
Shubham Dwivedi
 
PPTX
Method overloading
Lovely Professional University
 
PPTX
Methods in java
chauhankapil
 
PPTX
Function C programming
Appili Vamsi Krishna
 
PPTX
Templates in C++
Tech_MX
 
DOCX
Abstraction in c++ and Real Life Example of Abstraction in C++
Hitesh Kumar
 
PPTX
Presentation on array
topu93
 
PPTX
Array of objects.pptx
RAGAVIC2
 
PPTX
Java exception handling
BHUVIJAYAVELU
 
PPTX
Inline function in C++
Jenish Patel
 
PPT
Java interfaces
Raja Sekhar
 
PPTX
Dynamic memory allocation in c
lavanya marichamy
 
PPTX
Sparse matrix and its representation data structure
Vardhil Patel
 
PPTX
INHERITANCE IN JAVA.pptx
NITHISG1
 
PPTX
Destructors
DeepikaT13
 
PPT
Java Streams
M Vishnuvardhan Reddy
 
PPTX
Tokens in C++
Mahender Boda
 
ITFT-Constants, variables and data types in java
Atul Sehdev
 
JAVA AWT
shanmuga rajan
 
Java Exception handling
kamal kotecha
 
Java abstract class & abstract methods
Shubham Dwivedi
 
Method overloading
Lovely Professional University
 
Methods in java
chauhankapil
 
Function C programming
Appili Vamsi Krishna
 
Templates in C++
Tech_MX
 
Abstraction in c++ and Real Life Example of Abstraction in C++
Hitesh Kumar
 
Presentation on array
topu93
 
Array of objects.pptx
RAGAVIC2
 
Java exception handling
BHUVIJAYAVELU
 
Inline function in C++
Jenish Patel
 
Java interfaces
Raja Sekhar
 
Dynamic memory allocation in c
lavanya marichamy
 
Sparse matrix and its representation data structure
Vardhil Patel
 
INHERITANCE IN JAVA.pptx
NITHISG1
 
Destructors
DeepikaT13
 
Java Streams
M Vishnuvardhan Reddy
 
Tokens in C++
Mahender Boda
 
Ad

Similar to Java Array String (20)

PPTX
Arrays in java.pptx
Nagaraju Pamarthi
 
PDF
Arrays in java
TharuniDiddekunta
 
PPTX
Array.pptx
ssuser8698eb
 
PPTX
JAVA WORKSHOP(DAY 3) 1234567889999999.pptx
aniketraj4440
 
PPTX
Java Programming
Nanthini Kempaiyan
 
PPT
05slide_arrays_creation_searching_sorting.ppt
ramesh504657
 
PPTX
SessionPlans_f3efa1.6 Array in java.pptx
businessmarketing100
 
PPT
06slide
Dorothea Chaffin
 
PDF
Java R20 - UNIT-3.pdf Java R20 - UNIT-3.pdf
kamalabhushanamnokki
 
PDF
Arrays
ViniVini48
 
PPTX
Module 4_CSE3146-Advanced Java Programming-Anno_Lambda-PPTs.pptx
aruthras2323
 
PDF
Class notes(week 4) on arrays and strings
Kuntal Bhowmick
 
PDF
Arrays in Java
Naz Abdalla
 
PPTX
Computer programming 2 Lesson 13
MLG College of Learning, Inc
 
PDF
An Introduction to Programming in Java: Arrays
Martin Chapman
 
DOC
Lab exp declaring arrays)
Daman Toor
 
DOCX
Class notes(week 4) on arrays and strings
Kuntal Bhowmick
 
PPT
In this page, we will learn about the basics of OOPs. Object-Oriented Program...
Indu32
 
Arrays in java.pptx
Nagaraju Pamarthi
 
Arrays in java
TharuniDiddekunta
 
Array.pptx
ssuser8698eb
 
JAVA WORKSHOP(DAY 3) 1234567889999999.pptx
aniketraj4440
 
Java Programming
Nanthini Kempaiyan
 
05slide_arrays_creation_searching_sorting.ppt
ramesh504657
 
SessionPlans_f3efa1.6 Array in java.pptx
businessmarketing100
 
Java R20 - UNIT-3.pdf Java R20 - UNIT-3.pdf
kamalabhushanamnokki
 
Arrays
ViniVini48
 
Module 4_CSE3146-Advanced Java Programming-Anno_Lambda-PPTs.pptx
aruthras2323
 
Class notes(week 4) on arrays and strings
Kuntal Bhowmick
 
Arrays in Java
Naz Abdalla
 
Computer programming 2 Lesson 13
MLG College of Learning, Inc
 
An Introduction to Programming in Java: Arrays
Martin Chapman
 
Lab exp declaring arrays)
Daman Toor
 
Class notes(week 4) on arrays and strings
Kuntal Bhowmick
 
In this page, we will learn about the basics of OOPs. Object-Oriented Program...
Indu32
 
Ad

More from Manish Tiwari (8)

PPTX
Interview Question, Oracle PLSQL, PLSQL Developer
Manish Tiwari
 
PDF
Oracle SQL, Job Roles, Certification, DML Statement
Manish Tiwari
 
PPTX
Global Software Development, Work Outsourcing, Global Software Industry
Manish Tiwari
 
PPTX
Wavelet, Wavelet Image Compression, STW, SPIHT, MATLAB
Manish Tiwari
 
PPTX
Java Program Structure
Manish Tiwari
 
PPTX
Java Interface
Manish Tiwari
 
PPTX
Java Inheritance
Manish Tiwari
 
PDF
1 blogging manish_tiwari
Manish Tiwari
 
Interview Question, Oracle PLSQL, PLSQL Developer
Manish Tiwari
 
Oracle SQL, Job Roles, Certification, DML Statement
Manish Tiwari
 
Global Software Development, Work Outsourcing, Global Software Industry
Manish Tiwari
 
Wavelet, Wavelet Image Compression, STW, SPIHT, MATLAB
Manish Tiwari
 
Java Program Structure
Manish Tiwari
 
Java Interface
Manish Tiwari
 
Java Inheritance
Manish Tiwari
 
1 blogging manish_tiwari
Manish Tiwari
 

Recently uploaded (20)

PPTX
Information Texts_Infographic on Forgetting Curve.pptx
Tata Sevilla
 
PPTX
PPTs-The Rise of Empiresghhhhhhhh (1).pptx
academysrusti114
 
PPTX
Open Quiz Monsoon Mind Game Final Set.pptx
Sourav Kr Podder
 
PDF
The Picture of Dorian Gray summary and depiction
opaliyahemel
 
PPTX
Congenital Hypothyroidism pptx
AneetaSharma15
 
PPTX
Nursing Management of Patients with Disorders of Ear, Nose, and Throat (ENT) ...
RAKESH SAJJAN
 
PPTX
TEF & EA Bsc Nursing 5th sem.....BBBpptx
AneetaSharma15
 
PPTX
Tips Management in Odoo 18 POS - Odoo Slides
Celine George
 
PDF
UTS Health Student Promotional Representative_Position Description.pdf
Faculty of Health, University of Technology Sydney
 
PDF
Electricity-Magnetic-and-Heating-Effects 4th Chapter/8th-science-curiosity.pd...
Sandeep Swamy
 
PPTX
Dakar Framework Education For All- 2000(Act)
santoshmohalik1
 
PPTX
An introduction to Dialogue writing.pptx
drsiddhantnagine
 
PPTX
Open Quiz Monsoon Mind Game Prelims.pptx
Sourav Kr Podder
 
PDF
3.The-Rise-of-the-Marathas.pdfppt/pdf/8th class social science Exploring Soci...
Sandeep Swamy
 
PDF
PG-BPSDMP 2 TAHUN 2025PG-BPSDMP 2 TAHUN 2025.pdf
AshifaRamadhani
 
PPTX
ACUTE NASOPHARYNGITIS. pptx
AneetaSharma15
 
PPTX
How to Manage Global Discount in Odoo 18 POS
Celine George
 
DOCX
Action Plan_ARAL PROGRAM_ STAND ALONE SHS.docx
Levenmartlacuna1
 
PDF
1.Natural-Resources-and-Their-Use.ppt pdf /8th class social science Exploring...
Sandeep Swamy
 
PPTX
PREVENTIVE PEDIATRIC. pptx
AneetaSharma15
 
Information Texts_Infographic on Forgetting Curve.pptx
Tata Sevilla
 
PPTs-The Rise of Empiresghhhhhhhh (1).pptx
academysrusti114
 
Open Quiz Monsoon Mind Game Final Set.pptx
Sourav Kr Podder
 
The Picture of Dorian Gray summary and depiction
opaliyahemel
 
Congenital Hypothyroidism pptx
AneetaSharma15
 
Nursing Management of Patients with Disorders of Ear, Nose, and Throat (ENT) ...
RAKESH SAJJAN
 
TEF & EA Bsc Nursing 5th sem.....BBBpptx
AneetaSharma15
 
Tips Management in Odoo 18 POS - Odoo Slides
Celine George
 
UTS Health Student Promotional Representative_Position Description.pdf
Faculty of Health, University of Technology Sydney
 
Electricity-Magnetic-and-Heating-Effects 4th Chapter/8th-science-curiosity.pd...
Sandeep Swamy
 
Dakar Framework Education For All- 2000(Act)
santoshmohalik1
 
An introduction to Dialogue writing.pptx
drsiddhantnagine
 
Open Quiz Monsoon Mind Game Prelims.pptx
Sourav Kr Podder
 
3.The-Rise-of-the-Marathas.pdfppt/pdf/8th class social science Exploring Soci...
Sandeep Swamy
 
PG-BPSDMP 2 TAHUN 2025PG-BPSDMP 2 TAHUN 2025.pdf
AshifaRamadhani
 
ACUTE NASOPHARYNGITIS. pptx
AneetaSharma15
 
How to Manage Global Discount in Odoo 18 POS
Celine George
 
Action Plan_ARAL PROGRAM_ STAND ALONE SHS.docx
Levenmartlacuna1
 
1.Natural-Resources-and-Their-Use.ppt pdf /8th class social science Exploring...
Sandeep Swamy
 
PREVENTIVE PEDIATRIC. pptx
AneetaSharma15
 

Java Array String

  • 1. Array In Java Created by Manish Tiwari
  • 2. Presentation By Manish Tiwari, Assistant Professor, Software Engineer, Computer Science and Application
  • 3. 2. WhatsApp: ? 4. Blog: manishtiwarise.blogspot.in 3. Email: [email protected] 1. Twitter: @manishtiwarise 5. SlideShare: https://www.slideshare.net/tiwarikmanish Find Notes
  • 4. A R R A Y S 0 1 2 3 4 5 Element Index
  • 5. Array is a collection of similar type(Homogeneous) of elements stored in contiguous memory location. Definition of Java Array 1. Code Optimization: It makes the code optimized, we can retrieve or sort the data easily. 2. Random access: We can get any data located at any index position. Advantage of Java Array 1. Size Limit: We can store only fixed size of elements in the array. It doesn't grow its size at runtime. To solve this problem, collection framework is used in java. Disadvantage of Java Array
  • 6. 1. Single Dimensional Array Syntax: // preferred way. 1. DataType[] ArrayName; Example: double[] myList; 2. DataType ArrayName[]; Example: double myList[]; Types of Java Array 2. Multidimensional Array Syntax: // preferred way. 1. dataType[][] arrayRefVar; (or) 2. dataType [][]arrayRefVar; (or) 3. dataType arrayRefVar[][]; (or) 4. dataType []arrayRefVar[]; 0 There are Two Types of Array.
  • 7. class Testarray { public static void main(String args[]) { int a[]=new int[5];//declaration and instantiation a[0]=10;//initialization a[1]=20; a[2]=70; a[3]=40; a[4]=50; //printing array for(int i=0;i<a.length;i++)//length is the property of array System.out.println(a[i]); } } Program-Single Dimensional Array
  • 8. class Testarray1 { public static void main(String args[]) { int a[]={33,3,4,5}; //declaration, instantiation and initialization //printing array for(int i=0;i<a.length;i++) //length is the property of array System.out.println(a[i]); } } Declaration, Instantiation and Initialization of Java Array
  • 9. class Testarray5 { public static void main(String args[]){ int a[][]={{1,3,4},{3,4,5}}; int b[][]={{1,3,4},{3,4,5}}; int c[][]=new int[2][3]; for(int i=0;i<2;i++) { for(int j=0;j<3;j++) { c[i][j]=a[i][j]+b[i][j]; System.out.print(c[i][j]+" "); } System.out.println();//new line } } } Adding 2 Matrices Using Multi Dimensional
  • 10. String is a sequence of characters. But in java, string is an object that represents a sequence of characters. The java.lang.String class is used to create string object. String in Java String Types There are two ways to create String object: 1.By string literal String s="welcome"; 2. By new keyword String s=new String("Welcome");
  • 11. String Program public class StringExample { public static void main(String args[]) { String s1="java"; char ch[]={'s','t','r','i','n','g','s'}; String s2=new String(ch); String s3=new String("example"); System.out.println(s1); System.out.println(s2); System.out.println(s3); System.out.println(s1.toUpperCase()); System.out.println(s1.toLowerCase()); System.out.println(s2.charAt(3)); System.out.println(s2.length()); System.out.println(s3.trim()); System.out.println(s3.startsWith(“s"));//true System.out.println(s1.endsWith(“s"));//true } }