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

PPT
Java interfaces
PPTX
Member Function in C++
PPTX
Polymorphism presentation in java
PPS
Java Exception handling
PPTX
Methods in java
PPT
Exception Handling in JAVA
PDF
Object-oriented Programming-with C#
Java interfaces
Member Function in C++
Polymorphism presentation in java
Java Exception handling
Methods in java
Exception Handling in JAVA
Object-oriented Programming-with C#

What's hot (20)

PPTX
Arrays in Java
PPTX
Inheritance in JAVA PPT
PPTX
String, string builder, string buffer
PPT
Java static keyword
PPT
Generics in java
PPTX
Exception Handling in Java
PPT
C# Exceptions Handling
PPTX
Exceptions in Java
PPTX
Data types in java
PPTX
Java package
PPTX
Control statements in java
PPTX
Virtual base class
PPT
Thread model in java
PPTX
PPTX
Exception handling
PPTX
Constructor in java
PPTX
Classes objects in java
PPTX
Multithreading in java
PPTX
Chapter 07 inheritance
PPS
String and string buffer
Arrays in Java
Inheritance in JAVA PPT
String, string builder, string buffer
Java static keyword
Generics in java
Exception Handling in Java
C# Exceptions Handling
Exceptions in Java
Data types in java
Java package
Control statements in java
Virtual base class
Thread model in java
Exception handling
Constructor in java
Classes objects in java
Multithreading in java
Chapter 07 inheritance
String and string buffer
Ad

Similar to Java Array String (20)

PPTX
Arrays in java.pptx
PDF
Arrays in java
PPTX
Array.pptx
PPTX
JAVA WORKSHOP(DAY 3) 1234567889999999.pptx
PPTX
Java Programming
PPT
05slide_arrays_creation_searching_sorting.ppt
PPTX
SessionPlans_f3efa1.6 Array in java.pptx
PPT
PDF
Java R20 - UNIT-3.pdf Java R20 - UNIT-3.pdf
PDF
Arrays
PPTX
Module 4_CSE3146-Advanced Java Programming-Anno_Lambda-PPTs.pptx
PDF
Class notes(week 4) on arrays and strings
PDF
Arrays in Java
PPTX
Computer programming 2 Lesson 13
PDF
An Introduction to Programming in Java: Arrays
DOC
Lab exp declaring arrays)
DOCX
Class notes(week 4) on arrays and strings
PPT
In this page, we will learn about the basics of OOPs. Object-Oriented Program...
Arrays in java.pptx
Arrays in java
Array.pptx
JAVA WORKSHOP(DAY 3) 1234567889999999.pptx
Java Programming
05slide_arrays_creation_searching_sorting.ppt
SessionPlans_f3efa1.6 Array in java.pptx
Java R20 - UNIT-3.pdf Java R20 - UNIT-3.pdf
Arrays
Module 4_CSE3146-Advanced Java Programming-Anno_Lambda-PPTs.pptx
Class notes(week 4) on arrays and strings
Arrays in Java
Computer programming 2 Lesson 13
An Introduction to Programming in Java: Arrays
Lab exp declaring arrays)
Class notes(week 4) on arrays and strings
In this page, we will learn about the basics of OOPs. Object-Oriented Program...
Ad

More from Manish Tiwari (8)

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

Recently uploaded (20)

PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
Insiders guide to clinical Medicine.pdf
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PPTX
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PPTX
PPH.pptx obstetrics and gynecology in nursing
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PDF
01-Introduction-to-Information-Management.pdf
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PPTX
Cell Structure & Organelles in detailed.
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Renaissance Architecture: A Journey from Faith to Humanism
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
VCE English Exam - Section C Student Revision Booklet
Insiders guide to clinical Medicine.pdf
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
O5-L3 Freight Transport Ops (International) V1.pdf
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PPH.pptx obstetrics and gynecology in nursing
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
STATICS OF THE RIGID BODIES Hibbelers.pdf
Supply Chain Operations Speaking Notes -ICLT Program
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
01-Introduction-to-Information-Management.pdf
Abdominal Access Techniques with Prof. Dr. R K Mishra
Cell Structure & Organelles in detailed.

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: tiwarikmanish@gmail.com 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 } }