SlideShare a Scribd company logo
Java/J2EE Programming Training
Data Handling and Functions
Page 2Classification: Restricted
Agenda
• Implement Single and Multi dimensional array
• Declare and Define Functions
• Call Functions by value and by reference
• Implement Method Overloading
• Use String data-type and String-buffer
Page 3Classification: Restricted
Introduction to Arrays
Page 4Classification: Restricted
Meet John Again
Page 5Classification: Restricted
One day in office
Page 6Classification: Restricted
One day in office
6
Page 7Classification: Restricted
John’s Project – Question Statement
Page 8Classification: Restricted
Daisy was Confused!
Page 9Classification: Restricted
John already had a plan
Page 10Classification: Restricted
John Came up with a solution
Page 11Classification: Restricted
John’s Solution
Page 12Classification: Restricted
John Presented the Solution
Page 13Classification: Restricted
John gets a Promotion
Page 14Classification: Restricted
Why do we use Arrays?
• Arrays are an important structure to hold data.
• Java allows us to hold many objects of the same type using arrays and it can
be used with the help of a loop to access the elements by their index.
Page 15Classification: Restricted
Arrays
Page 16Classification: Restricted
Declaring Arrays
Page 17Classification: Restricted
Declaring Arrays
Page 18Classification: Restricted
Declaring Arrays
• Arrays can be declared for primitive and non-primitive data types.
• Instead of declaring int a1, a2, a3, a4....a100, we can declare int
a[100].
• It is fast and efficient to access an element in an array using the
corresponding index without actually traversing through the entire
array.
• The size of the array is fixed once it is created.
• For Example: A character array of 10 characters can be declared as
Page 19Classification: Restricted
Types of Arrays
Page 20Classification: Restricted
How Single Dimensional Arrays are used?
Page 21Classification: Restricted
Multidimentional Array
• Multi dimensional arrays can be 2 dimensional as rows and columns similar
to a matrix or it could be 3 dimensional with depth, height and breadth or it
could be 'n' dimensional array as per the requirement.
• Multi-dimensional arrays can be declared as
• Usually 2 dimensional arrays are used to perform matrix operations.
• Like single dimensional arrays, multi dimensional arrays can be of primitive
and nonprimitive data type.
Page 22Classification: Restricted
Question
How many bytes are allocated for the array x?
int x[][] = new int[5][5];
Page 23Classification: Restricted
Answer
An int element takes 4 bytes and array x can store 25
int elements.
Hence total number of bytes taken by x is 25*4 = 100
Page 24Classification: Restricted
Question
Can we do multi dimensional array operations in
single dimensional array?
If yes, then why do we require multi dimensional
array?
Page 25Classification: Restricted
Answer
We can perform all the operations of multi
dimensional array in single dimensional array but
when the data has more than one dimension, it will
be easier to perform operations in multi
dimensional array.
Page 26Classification: Restricted
LAB
Page 27Classification: Restricted
Function
Page 28Classification: Restricted
Daisy Seek’s Help
Page 29Classification: Restricted
John helps Daisy
Page 30Classification: Restricted
John helps Daisy
Page 31Classification: Restricted
John explain Functions
Page 32Classification: Restricted
John helps Daisy
Page 33Classification: Restricted
Functions
• Scope specifier modifier return type function name (arguments)
• A function/method has group of statements to be executed.
• A function has a task to perform.
• A function is declared as public static void say Hello(int a, int b)
Page 34Classification: Restricted
Why do we use functions?
• We use functions to provide different kinds of functionality.
• For example:
• absolute()
• To find the absolute value of a number.
• square()
• To find the square of a number.
• sqrt()
• To find the square root of a number.
Page 35Classification: Restricted
Features of Functions
• Scope specifier
• This option specifies the visibility of the function. It could be public,
private, protected or default (package).
• Modifier
• This is optional.
• This will change the meaning of the function. Some of the options could
be final, static, native,synchronized etc.
• Return type
• This option specifies the data that will be returned by the function.
• It could be primitive data type or objects.
• Function name
• It is the name given to the function. Using function name, functions can
be invoked.
• Arguments
• This is optional but can be used. Using this, one can pass values to the
function for computation.
Page 36Classification: Restricted
What happens when a Function is Invoked?
• When a function is called from the main method, main method() address is
stored on top of the stack.
• Control jumps to execute the function.
• After executing the function, main method address is popped from the
stack and main
method execution resumes.
Page 37Classification: Restricted
What happens when a function is invoked?
Page 38Classification: Restricted
What happens when a function is invoked?
Page 39Classification: Restricted
What happens when a function is invoked?
Page 40Classification: Restricted
What happens when a Function is Invoked?
Page 41Classification: Restricted
What happens when a Function is Invoked?
Page 42Classification: Restricted
Sample program on Function
Page 43Classification: Restricted
Sample program on Functions (Contind..)
Page 44Classification: Restricted
Sample program on Functions(Contd..)
4
Page 45Classification: Restricted
Sample Program on Functions (contd..)
Page 46Classification: Restricted
Sample Program on Functions (contd..)
Page 47Classification: Restricted
Function Calling ways
Page 48Classification: Restricted
Call by Value
• When value of the
primitive data type is
passed as an argument
from the calling
function, data is being
sent to the function.
• At the receiving end, a
new variable is created
and the data is copied.
This is call by value.
• All the programs we
have done till now
is done using call by
value.
Page 49Classification: Restricted
Call by Reference
Page 50Classification: Restricted
Call by Reference
Page 51Classification: Restricted
Polymorphism
Page 52Classification: Restricted
Function Overloading
Page 53Classification: Restricted
Function Overloading (contd.)
Page 54Classification: Restricted
Function Overloading (contd.)
Page 55Classification: Restricted
Function Overloading
Page 56Classification: Restricted
Function Overloading
5
Page 57Classification: Restricted
Program on Function Overloading
Page 58Classification: Restricted
Meet Mr. Letter and Miss Sentence!
Page 59Classification: Restricted
Mr.Letter is from “char datatype”
Page 60Classification: Restricted
Miss Sentence is sad!
Page 61Classification: Restricted
Miss Sentence has her own Place in Java
Page 62Classification: Restricted
Why do we use String?
Page 63Classification: Restricted
String
• String is a class in Java to store string data.
• You can assign string data simply by defining the string object and assign
the string like this:
• You can concatenate two string using + symbol.
• For Example:
• Output of the program is
• Appended string is: HelloWorld
String str;
String str = “Focusthread”
String str = new String (“Focusthread”);
Page 64Classification: Restricted
Where do we use string?
Page 65Classification: Restricted
String Functions
• length()
• Returns the length of the string.
• charAt(int)
• Returns a character at the specified position. Index of the String starts from 0.
• concat (String str)
• It concatenates the with the string object. It is same as using '+' operator for
concatenation.
• equals(String str)
• Checks whether string object and str and return true if they are same else
returns false.
• EqulsIgnoreCase (String str)
• Same as above function except that this function ignores the case and checks
for the equality of the strings.
• indexOf(String str)
• Returns the index of the specified string in the string object.
• lastIndexOf(String str)
• Same as above function but checks from back of the string.
Page 66Classification: Restricted
String Functions
• replace(char ch, char ch1)
• Replaces the character ch with Character ch1 in the string.
• toLowerCase()
• Converts the given string to lowercase.
• toUpperCase()
• Converts the given string to uppercase.
• trim()
• Removes the leading and trailing spaces of the string.
Page 67Classification: Restricted
LAB
Page 68Classification: Restricted
StringBuffer
Page 69Classification: Restricted
Question
When should we use String and
StringBuffer? why?
Page 70Classification: Restricted
Answer
When we do not need to modify string objects then
String can be used else using StringBuffer is a better
option since it is mutable.
Page 71Classification: Restricted
Program on StringBuffer
Page 72Classification: Restricted
StringBuider
Page 73Classification: Restricted
StringBuilder Constructors
Page 74Classification: Restricted
Assignment – Single Dimentional Array
Page 75Classification: Restricted
Assignment – Two Dimentational Array
Page 76Classification: Restricted
Assignment - Functions
Page 77Classification: Restricted
Assignment – Functions Overloading
Page 78Classification: Restricted
Module Assignment
Page 79Classification: Restricted
Module Assignment
Page 80Classification: Restricted
Module Assignment
Page 81Classification: Restricted
Agenda for Next Class
Page 82Classification: Restricted
Pre work
Page 83Classification: Restricted
Thank You

More Related Content

What's hot (13)

PPTX
L9 wrapper classes
teach4uin
 
PDF
String handling(string buffer class)
Ravi Kant Sahu
 
PDF
Wrapper classes
Ravi_Kant_Sahu
 
PPT
3. Data types and Variables
Nilesh Dalvi
 
PPTX
Java tutorial part 3
Mumbai Academisc
 
PPT
Chapter 4 strings
Chv Raghavendran
 
PPTX
Session 10 - OOP with Java - Abstract Classes and Interfaces
PawanMM
 
PDF
Text categorization as graph
Harry Potter
 
PDF
Automatic Document Summarization
Findwise
 
PDF
The Ring programming language version 1.5.3 book - Part 187 of 194
Mahmoud Samir Fayed
 
PDF
The Ring programming language version 1.7 book - Part 90 of 196
Mahmoud Samir Fayed
 
L9 wrapper classes
teach4uin
 
String handling(string buffer class)
Ravi Kant Sahu
 
Wrapper classes
Ravi_Kant_Sahu
 
3. Data types and Variables
Nilesh Dalvi
 
Java tutorial part 3
Mumbai Academisc
 
Chapter 4 strings
Chv Raghavendran
 
Session 10 - OOP with Java - Abstract Classes and Interfaces
PawanMM
 
Text categorization as graph
Harry Potter
 
Automatic Document Summarization
Findwise
 
The Ring programming language version 1.5.3 book - Part 187 of 194
Mahmoud Samir Fayed
 
The Ring programming language version 1.7 book - Part 90 of 196
Mahmoud Samir Fayed
 

Similar to Data Handling and Function (20)

PPT
java tutorial 2
Tushar Desarda
 
PPSX
Dr. Rajeshree Khande : Programming concept of basic java
jalinder123
 
PPSX
Dr. Rajeshree Khande : Java Basics
DrRajeshreeKhande
 
PPTX
Java chapter 2
Abdii Rashid
 
PPTX
Session 06 - Java Basics
SiddharthSelenium
 
PPTX
Ifi7184.DT lesson 2
Sónia
 
PPTX
Fundamental programming structures in java
Shashwat Shriparv
 
PPT
Md03 - part3
Rakesh Madugula
 
PPT
Lesson3
Arpan91
 
PPT
Lesson3
Arvind Shah
 
PPT
2.DATA TYPES_MB_2022.ppt .
happycocoman
 
PPTX
UNIT 1 : object oriented programming.pptx
amanuel236786
 
PPT
demo1 java of demo 1 java with demo 1 java.ppt
FerdieBalang
 
PPTX
Identifiers, keywords and types
Daman Toor
 
PPTX
01 Java Language And OOP PART I
Hari Christian
 
PDF
Java session 3
Rajeev Kumar
 
PDF
Json demo
Sreeni I
 
PPTX
03 and 04 .Operators, Expressions, working with the console and conditional s...
Intro C# Book
 
PDF
Chapter 01 Introduction to Java by Tushar B Kute
Tushar B Kute
 
PPTX
Java fundamentals
HCMUTE
 
java tutorial 2
Tushar Desarda
 
Dr. Rajeshree Khande : Programming concept of basic java
jalinder123
 
Dr. Rajeshree Khande : Java Basics
DrRajeshreeKhande
 
Java chapter 2
Abdii Rashid
 
Session 06 - Java Basics
SiddharthSelenium
 
Ifi7184.DT lesson 2
Sónia
 
Fundamental programming structures in java
Shashwat Shriparv
 
Md03 - part3
Rakesh Madugula
 
Lesson3
Arpan91
 
Lesson3
Arvind Shah
 
2.DATA TYPES_MB_2022.ppt .
happycocoman
 
UNIT 1 : object oriented programming.pptx
amanuel236786
 
demo1 java of demo 1 java with demo 1 java.ppt
FerdieBalang
 
Identifiers, keywords and types
Daman Toor
 
01 Java Language And OOP PART I
Hari Christian
 
Java session 3
Rajeev Kumar
 
Json demo
Sreeni I
 
03 and 04 .Operators, Expressions, working with the console and conditional s...
Intro C# Book
 
Chapter 01 Introduction to Java by Tushar B Kute
Tushar B Kute
 
Java fundamentals
HCMUTE
 
Ad

More from RatnaJava (14)

PPTX
Review Session and Attending Java Interviews
RatnaJava
 
PPTX
Collections - Lists & sets
RatnaJava
 
PPTX
Collections - Sorting, Comparing Basics
RatnaJava
 
PPTX
Collections Array list
RatnaJava
 
PPTX
Object Class
RatnaJava
 
PPTX
Exception Handling
RatnaJava
 
PPTX
OOPs with Java - Packaging and Access Modifiers
RatnaJava
 
PPTX
OOP with Java - Abstract Classes and Interfaces
RatnaJava
 
PPTX
OOP with Java - Part 3
RatnaJava
 
PPTX
OOP with Java - continued
RatnaJava
 
PPTX
Object Oriented Programming
RatnaJava
 
PPTX
Introduction to Java Part-3
RatnaJava
 
PPTX
Introduction to Java Part-2
RatnaJava
 
PPTX
Introduction to Java
RatnaJava
 
Review Session and Attending Java Interviews
RatnaJava
 
Collections - Lists & sets
RatnaJava
 
Collections - Sorting, Comparing Basics
RatnaJava
 
Collections Array list
RatnaJava
 
Object Class
RatnaJava
 
Exception Handling
RatnaJava
 
OOPs with Java - Packaging and Access Modifiers
RatnaJava
 
OOP with Java - Abstract Classes and Interfaces
RatnaJava
 
OOP with Java - Part 3
RatnaJava
 
OOP with Java - continued
RatnaJava
 
Object Oriented Programming
RatnaJava
 
Introduction to Java Part-3
RatnaJava
 
Introduction to Java Part-2
RatnaJava
 
Introduction to Java
RatnaJava
 
Ad

Recently uploaded (20)

PDF
SFWelly Summer 25 Release Highlights July 2025
Anna Loughnan Colquhoun
 
PDF
Windsurf Meetup Ottawa 2025-07-12 - Planning Mode at Reliza.pdf
Pavel Shukhman
 
PDF
Français Patch Tuesday - Juillet
Ivanti
 
PDF
Women in Automation Presents: Reinventing Yourself — Bold Career Pivots That ...
DianaGray10
 
PDF
Blockchain Transactions Explained For Everyone
CIFDAQ
 
PDF
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
PPTX
Top iOS App Development Company in the USA for Innovative Apps
SynapseIndia
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PDF
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
PPTX
Darren Mills The Migration Modernization Balancing Act: Navigating Risks and...
AWS Chicago
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PDF
Empowering Cloud Providers with Apache CloudStack and Stackbill
ShapeBlue
 
PDF
Ampere Offers Energy-Efficient Future For AI And Cloud
ShapeBlue
 
PDF
Why Orbit Edge Tech is a Top Next JS Development Company in 2025
mahendraalaska08
 
PPT
Interview paper part 3, It is based on Interview Prep
SoumyadeepGhosh39
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PDF
TrustArc Webinar - Data Privacy Trends 2025: Mid-Year Insights & Program Stra...
TrustArc
 
PDF
Rethinking Security Operations - SOC Evolution Journey.pdf
Haris Chughtai
 
SFWelly Summer 25 Release Highlights July 2025
Anna Loughnan Colquhoun
 
Windsurf Meetup Ottawa 2025-07-12 - Planning Mode at Reliza.pdf
Pavel Shukhman
 
Français Patch Tuesday - Juillet
Ivanti
 
Women in Automation Presents: Reinventing Yourself — Bold Career Pivots That ...
DianaGray10
 
Blockchain Transactions Explained For Everyone
CIFDAQ
 
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
Top iOS App Development Company in the USA for Innovative Apps
SynapseIndia
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
Darren Mills The Migration Modernization Balancing Act: Navigating Risks and...
AWS Chicago
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
Empowering Cloud Providers with Apache CloudStack and Stackbill
ShapeBlue
 
Ampere Offers Energy-Efficient Future For AI And Cloud
ShapeBlue
 
Why Orbit Edge Tech is a Top Next JS Development Company in 2025
mahendraalaska08
 
Interview paper part 3, It is based on Interview Prep
SoumyadeepGhosh39
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
TrustArc Webinar - Data Privacy Trends 2025: Mid-Year Insights & Program Stra...
TrustArc
 
Rethinking Security Operations - SOC Evolution Journey.pdf
Haris Chughtai
 

Data Handling and Function