SlideShare a Scribd company logo
1 of 26
 Packages are used in Java in order to prevent
naming conflicts, to control access, to make
searching/locating and usage of classes, interfaces,
enumerations and annotations easier.
 A Package can be defined as a grouping
of related types (classes, interfaces,
enumerations and annotations ) providing
access protection and namespace management.
The Exception Handling in Java is one
of the powerful mechanism to handle the
runtime errors so that normal flow of the
application can be maintained.
Types of Java Exceptions
 Checked Exception
 Unchecked Exception
 Error
 Checked Exception
The classes which directly inherit Throwable class
except RuntimeException and Error are known as
checked exceptions e.g. IOException, SQLException
etc. Checked exceptions are checked at compile-time.
 Unchecked Exception
The classes which inherit RuntimeException are
known as unchecked exceptions e.g.
ArithmeticException, NullPointerException,
ArrayIndexOutOfBoundsException etc. Unchecked
exceptions are not checked at compile-time, but they
are checked at runtime.
 Error
Error is irrecoverable e.g. OutOfMemoryError,
VirtualMachineError, AssertionError etc.
Example:
public class JavaExceptionExample{
public static void main(String args[]){
try{
int data=100/0;
}
catch(ArithmeticException e){System.out.println(e);}
System.out.println("rest of the code...");
}
}
 Multithreading is a Java feature that allows concurrent
execution of two or more parts of a program for
maximum utilization of CPU. Each part of such
program is called a thread. So, threads are light-weight
processes within a process.
 Threads can be created by using two mechanisms :
1. Extending the Thread class
2. Implementing the Runnable Interface
 Thread creation by extending the Thread class:
We create a class that extends the java.lang.Thread
class. This class overrides the run() method available in
the Thread class. A thread begins its life inside run()
method. We create an object of our new class and call
start() method to start the execution of a thread. Start()
invokes the run() method on the Thread object.
 Thread creation by implementing the Runnable
Interface
We create a new class which implements
java.lang.Runnable interface and override run() method.
Then we instantiate a Thread object and call start()
method on this object.
The String object can be created explicitly by using the new
keyword and a constructor in the same way as you have
created objects previously. For example: The statement
String strl =new String("Java");
creates a String object initialized to the value of the string
literal "Java" and assigns a reference to string reference
variable str. Here, String ("Java") is actually a constructor of
the form String (string literal). When this statement is
compiled , the Java compiler invokes this constructor and
initializes the String object with the string literal enclosed in
parentheses which is passed as an argument.
 Example:
public class StringConstructors
{
public static void main(String[] args)
{
char[] charArray ={'H','i',' ','D','I','N','E','S','H'};
byte[] ascii ={65,66,67,68,70,71,73};
String str = "Welcome";
String strl =new String("Java");
String str2 =new String(charArray);
String str3 =new String(charArray,3,3);
String str4 =new String(ascii);
String str5 =new String(ascii,2,3);
String str6 =new String();
String str7 =new String(str);
System.out.println("str : "+ str);
System.out.println("strl : "+ strl);
System.out.println("str2 : "+ str2);
System.out.println("str3 : "+ str3);
System.out.println("str4 : "+ str4);
System.out.println("str5 : "+ str5);
System.out.println("str6 : "+ str6);
System.out.println("str7 : "+ str7);
str += " Dinesh Thakur";
System.out.println("str : "+ str);
}
}
 String Handling concept is storing the
string data in the main memory (RAM),
manipulating the data of the String,
retrieving the part of the String etc.
String Handling provides a lot of
concepts that can be performed on a
string such as concatenation of string,
comparison of string, find sub string etc.
 StringBuffer is a peer class of String
that provides much of the functionality of
strings. String represents fixed-length,
immutable character sequences while
StringBuffer represents growable and
writable character sequences.
 StringBuffer may have characters and
substrings inserted in the middle or
appended to the end. It will automatically
grow to make room for such additions
and often has more characters
preallocated than are actually needed, to
allow room for growth.
String Buffer Constructors:
 String Buffer()
 String Buffer(int size)
 String Buffer(String str)
 String Buffer(CharSequence chars)
StringBuffer Constructors:
StringBuffer( ):
It reserves room for 16 characters
without reallocation.
StringBuffer s=new StringBuffer();
StringBuffer( int size):
It accepts an integer argument that
explicitly sets the size of the buffer.
StringBuffer s=new StringBuffer(20);
StringBuffer(String str):
 It accepts a String argument that sets the
initial contents of the StringBuffer object and
reserves room for 16 more characters without
reallocation.
 StringBuffer s =
newStringBuffer("GeeksforGeeks");
 Methods:
Some of the most used methods are:
length( ) and capacity( ): The length of a
StringBuffer can be found by the length( )
method, while the total allocated capacity()
methord.
 int length()
 int capacity()
append( ):
It is used to add text at the end of the
existence text. Here are a few of its forms:
 StringBuffer append(String str)
 StringBuffer append(int num) .
insert( ):
It is used to insert text at the specified
index position. These are a few of its forms:
 StringBuffer insert(int index, String str)
 StringBuffer insert(int index, char ch)
 delete( ) and deleteCharAt( ):
o It can delete characters within a StringBuffer
by using the methods delete( ) and
deleteCharAt( ).
o The delete( ) method deletes a sequence of
characters from the invoking object.
o The deleteCharAt( ) method deletes the
character at the index specified by loc.
 StringBuffer delete(int startIndex,
int endIndex)
 StringBuffer deleteCharAt(int loc)
 replace( ):
It can replace one set of characters
with another set inside a StringBuffer
object by calling replace( ). The substring
being replaced is specified by the indexes
start Index and endIndex.
 StringBuffer replace(int startIndex, int
endIndex, String str)
 ensureCapacity( ):
It is used to increase the capacity of a
StringBuffer object. The new capacity will be
set to either the value we specify or twice the
current capacity plus two (i.e. capacity+2),
whichever is larger. Here, capacity specifies
the size of the buffer.
 void ensureCapacity(int capacity)
getchars():
To copy of a substring of a stringbuffer
into a array, use the getchars()
method().Sourcestart specifies the index of the
beginning of the substring, and source end
specifies an index of the end substring.
 Void getchars(int souceStart, int sourceEnd,
char target[], int targetstart)
 reverse():
You can reverse the characters within string
buffer object using reverse().
 String buffer reverse()
 substring():
You can obtain a portion of a string buffer by
calling substring().
 String substring(int starIndex)
 String substring(int startIndex, int endIndex)
 J2SE 5 adds a new string class to Java’s already
powerful string handling capabilities. This new
class is called String Builder.
 It is identical to String Buffer except for one
important difference: it is not synchronized, which
means that it is not thread-safe.
 The advantage of String Builder is faster
performance. However, in cases in which you are
using multithreading, you must use String Buffer
rather than String Builder.
THANK YOU

More Related Content

What's hot

Introduction to Java Strings, By Kavita Ganesan
Introduction to Java Strings, By Kavita GanesanIntroduction to Java Strings, By Kavita Ganesan
Introduction to Java Strings, By Kavita GanesanKavita Ganesan
 
String Builder & String Buffer (Java Programming)
String Builder & String Buffer (Java Programming)String Builder & String Buffer (Java Programming)
String Builder & String Buffer (Java Programming)Anwar Hasan Shuvo
 
Dive into Python Class
Dive into Python ClassDive into Python Class
Dive into Python ClassJim Yeh
 
String handling session 5
String handling session 5String handling session 5
String handling session 5Raja Sekhar
 
String handling(string class)
String handling(string class)String handling(string class)
String handling(string class)Ravi Kant Sahu
 
Dr. Rajeshree Khande - Java Interactive input
Dr. Rajeshree Khande - Java Interactive inputDr. Rajeshree Khande - Java Interactive input
Dr. Rajeshree Khande - Java Interactive inputjalinder123
 
Protocols with Associated Types, and How They Got That Way
Protocols with Associated Types, and How They Got That WayProtocols with Associated Types, and How They Got That Way
Protocols with Associated Types, and How They Got That WayAlexis Gallagher
 
Dotnet programming concepts difference faqs- 2
Dotnet programming concepts difference faqs- 2Dotnet programming concepts difference faqs- 2
Dotnet programming concepts difference faqs- 2Umar Ali
 
The Swift Compiler and Standard Library
The Swift Compiler and Standard LibraryThe Swift Compiler and Standard Library
The Swift Compiler and Standard LibrarySantosh Rajan
 
Anton Kasyanov, Introduction to Python, Lecture5
Anton Kasyanov, Introduction to Python, Lecture5Anton Kasyanov, Introduction to Python, Lecture5
Anton Kasyanov, Introduction to Python, Lecture5Anton Kasyanov
 
Java - Strings Concepts
Java - Strings ConceptsJava - Strings Concepts
Java - Strings ConceptsVicter Paul
 

What's hot (19)

Introduction to Java Strings, By Kavita Ganesan
Introduction to Java Strings, By Kavita GanesanIntroduction to Java Strings, By Kavita Ganesan
Introduction to Java Strings, By Kavita Ganesan
 
String Builder & String Buffer (Java Programming)
String Builder & String Buffer (Java Programming)String Builder & String Buffer (Java Programming)
String Builder & String Buffer (Java Programming)
 
Dive into Python Class
Dive into Python ClassDive into Python Class
Dive into Python Class
 
String handling session 5
String handling session 5String handling session 5
String handling session 5
 
07slide
07slide07slide
07slide
 
String handling(string class)
String handling(string class)String handling(string class)
String handling(string class)
 
Dr. Rajeshree Khande - Java Interactive input
Dr. Rajeshree Khande - Java Interactive inputDr. Rajeshree Khande - Java Interactive input
Dr. Rajeshree Khande - Java Interactive input
 
StringTokenizer in java
StringTokenizer in javaStringTokenizer in java
StringTokenizer in java
 
Programming with Python
Programming with PythonProgramming with Python
Programming with Python
 
Protocols with Associated Types, and How They Got That Way
Protocols with Associated Types, and How They Got That WayProtocols with Associated Types, and How They Got That Way
Protocols with Associated Types, and How They Got That Way
 
Dotnet programming concepts difference faqs- 2
Dotnet programming concepts difference faqs- 2Dotnet programming concepts difference faqs- 2
Dotnet programming concepts difference faqs- 2
 
The Swift Compiler and Standard Library
The Swift Compiler and Standard LibraryThe Swift Compiler and Standard Library
The Swift Compiler and Standard Library
 
Java strings
Java   stringsJava   strings
Java strings
 
Anton Kasyanov, Introduction to Python, Lecture5
Anton Kasyanov, Introduction to Python, Lecture5Anton Kasyanov, Introduction to Python, Lecture5
Anton Kasyanov, Introduction to Python, Lecture5
 
M C6java7
M C6java7M C6java7
M C6java7
 
Java - Strings Concepts
Java - Strings ConceptsJava - Strings Concepts
Java - Strings Concepts
 
Unit 4 qba
Unit 4 qbaUnit 4 qba
Unit 4 qba
 
About Python
About PythonAbout Python
About Python
 
Unit 4 qba
Unit 4 qbaUnit 4 qba
Unit 4 qba
 

Similar to package

String Handling, Inheritance, Packages and Interfaces
String Handling, Inheritance, Packages and InterfacesString Handling, Inheritance, Packages and Interfaces
String Handling, Inheritance, Packages and InterfacesPrabu U
 
javastringexample problems using string class
javastringexample problems using string classjavastringexample problems using string class
javastringexample problems using string classfedcoordinator
 
L14 string handling(string buffer class)
L14 string handling(string buffer class)L14 string handling(string buffer class)
L14 string handling(string buffer class)teach4uin
 
Java string handling
Java string handlingJava string handling
Java string handlingSalman Khan
 
Strings Arrays
Strings ArraysStrings Arrays
Strings Arraysphanleson
 
CSE 220 Assignment 3 Hints and Tips Some hints for approa.docx
CSE 220 Assignment 3 Hints and Tips  Some hints for approa.docxCSE 220 Assignment 3 Hints and Tips  Some hints for approa.docx
CSE 220 Assignment 3 Hints and Tips Some hints for approa.docxfaithxdunce63732
 
In the given example only one object will be created. Firstly JVM will not fi...
In the given example only one object will be created. Firstly JVM will not fi...In the given example only one object will be created. Firstly JVM will not fi...
In the given example only one object will be created. Firstly JVM will not fi...Indu32
 
Chapter 9 - Characters and Strings
Chapter 9 - Characters and StringsChapter 9 - Characters and Strings
Chapter 9 - Characters and StringsEduardo Bergavera
 
Fileoperations.pptx
Fileoperations.pptxFileoperations.pptx
Fileoperations.pptxVeenaNaik23
 
Java căn bản - Chapter9
Java căn bản - Chapter9Java căn bản - Chapter9
Java căn bản - Chapter9Vince Vo
 
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
 
String handling(string buffer class)
String handling(string buffer class)String handling(string buffer class)
String handling(string buffer class)Ravi_Kant_Sahu
 

Similar to package (20)

String Handling, Inheritance, Packages and Interfaces
String Handling, Inheritance, Packages and InterfacesString Handling, Inheritance, Packages and Interfaces
String Handling, Inheritance, Packages and Interfaces
 
javastringexample problems using string class
javastringexample problems using string classjavastringexample problems using string class
javastringexample problems using string class
 
Strings in Java
Strings in JavaStrings in Java
Strings in Java
 
L14 string handling(string buffer class)
L14 string handling(string buffer class)L14 string handling(string buffer class)
L14 string handling(string buffer class)
 
String handling
String handlingString handling
String handling
 
StringBuffer.pptx
StringBuffer.pptxStringBuffer.pptx
StringBuffer.pptx
 
Day_5.1.pptx
Day_5.1.pptxDay_5.1.pptx
Day_5.1.pptx
 
Lecture 7
Lecture 7Lecture 7
Lecture 7
 
Java string handling
Java string handlingJava string handling
Java string handling
 
Strings Arrays
Strings ArraysStrings Arrays
Strings Arrays
 
CSE 220 Assignment 3 Hints and Tips Some hints for approa.docx
CSE 220 Assignment 3 Hints and Tips  Some hints for approa.docxCSE 220 Assignment 3 Hints and Tips  Some hints for approa.docx
CSE 220 Assignment 3 Hints and Tips Some hints for approa.docx
 
Strings
StringsStrings
Strings
 
In the given example only one object will be created. Firstly JVM will not fi...
In the given example only one object will be created. Firstly JVM will not fi...In the given example only one object will be created. Firstly JVM will not fi...
In the given example only one object will be created. Firstly JVM will not fi...
 
Chapter 9 - Characters and Strings
Chapter 9 - Characters and StringsChapter 9 - Characters and Strings
Chapter 9 - Characters and Strings
 
Fileoperations.pptx
Fileoperations.pptxFileoperations.pptx
Fileoperations.pptx
 
Java căn bản - Chapter9
Java căn bản - Chapter9Java căn bản - Chapter9
Java căn bản - Chapter9
 
Java
JavaJava
Java
 
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
 
Java String Handling
Java String HandlingJava String Handling
Java String Handling
 
String handling(string buffer class)
String handling(string buffer class)String handling(string buffer class)
String handling(string buffer class)
 

More from sweetysweety8

More from sweetysweety8 (20)

Artificial neural network
Artificial neural networkArtificial neural network
Artificial neural network
 
Compiler Design
Compiler DesignCompiler Design
Compiler Design
 
Software engineering
Software engineeringSoftware engineering
Software engineering
 
Software engineering
Software engineeringSoftware engineering
Software engineering
 
WEB PROGRAMMING ANALYSIS
WEB PROGRAMMING ANALYSISWEB PROGRAMMING ANALYSIS
WEB PROGRAMMING ANALYSIS
 
Software engineering
Software engineeringSoftware engineering
Software engineering
 
Software engineering
Software engineeringSoftware engineering
Software engineering
 
Compiler Design
Compiler DesignCompiler Design
Compiler Design
 
WEB PROGRAMMING ANALYSIS
WEB PROGRAMMING ANALYSISWEB PROGRAMMING ANALYSIS
WEB PROGRAMMING ANALYSIS
 
WEB PROGRAMMING
WEB PROGRAMMINGWEB PROGRAMMING
WEB PROGRAMMING
 
Bigdata
BigdataBigdata
Bigdata
 
BIG DATA ANALYTICS
BIG DATA ANALYTICSBIG DATA ANALYTICS
BIG DATA ANALYTICS
 
BIG DATA ANALYTICS
BIG DATA ANALYTICSBIG DATA ANALYTICS
BIG DATA ANALYTICS
 
Compiler Design
Compiler DesignCompiler Design
Compiler Design
 
WEB PROGRAMMING
WEB PROGRAMMINGWEB PROGRAMMING
WEB PROGRAMMING
 
BIG DATA ANALYTICS
BIG DATA ANALYTICSBIG DATA ANALYTICS
BIG DATA ANALYTICS
 
Data mining
Data miningData mining
Data mining
 
Operating System
Operating SystemOperating System
Operating System
 
Relational Database Management System
Relational Database Management SystemRelational Database Management System
Relational Database Management System
 
Relational Database Management System
Relational Database Management SystemRelational Database Management System
Relational Database Management System
 

Recently uploaded

Call Girls in Rohini Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Rohini Delhi 💯Call Us 🔝8264348440🔝Call Girls in Rohini Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Rohini Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
The Ten Facts About People With Autism Presentation
The Ten Facts About People With Autism PresentationThe Ten Facts About People With Autism Presentation
The Ten Facts About People With Autism PresentationNathan Young
 
Gaps, Issues and Challenges in the Implementation of Mother Tongue Based-Mult...
Gaps, Issues and Challenges in the Implementation of Mother Tongue Based-Mult...Gaps, Issues and Challenges in the Implementation of Mother Tongue Based-Mult...
Gaps, Issues and Challenges in the Implementation of Mother Tongue Based-Mult...marjmae69
 
SBFT Tool Competition 2024 -- Python Test Case Generation Track
SBFT Tool Competition 2024 -- Python Test Case Generation TrackSBFT Tool Competition 2024 -- Python Test Case Generation Track
SBFT Tool Competition 2024 -- Python Test Case Generation TrackSebastiano Panichella
 
Open Source Strategy in Logistics 2015_Henrik Hankedvz-d-nl-log-conference.pdf
Open Source Strategy in Logistics 2015_Henrik Hankedvz-d-nl-log-conference.pdfOpen Source Strategy in Logistics 2015_Henrik Hankedvz-d-nl-log-conference.pdf
Open Source Strategy in Logistics 2015_Henrik Hankedvz-d-nl-log-conference.pdfhenrik385807
 
LANDMARKS AND MONUMENTS IN NIGERIA.pptx
LANDMARKS  AND MONUMENTS IN NIGERIA.pptxLANDMARKS  AND MONUMENTS IN NIGERIA.pptx
LANDMARKS AND MONUMENTS IN NIGERIA.pptxBasil Achie
 
Simulation-based Testing of Unmanned Aerial Vehicles with Aerialist
Simulation-based Testing of Unmanned Aerial Vehicles with AerialistSimulation-based Testing of Unmanned Aerial Vehicles with Aerialist
Simulation-based Testing of Unmanned Aerial Vehicles with AerialistSebastiano Panichella
 
Mathan flower ppt.pptx slide orchids ✨🌸
Mathan flower ppt.pptx slide orchids ✨🌸Mathan flower ppt.pptx slide orchids ✨🌸
Mathan flower ppt.pptx slide orchids ✨🌸mathanramanathan2005
 
Exploring protein-protein interactions by Weak Affinity Chromatography (WAC) ...
Exploring protein-protein interactions by Weak Affinity Chromatography (WAC) ...Exploring protein-protein interactions by Weak Affinity Chromatography (WAC) ...
Exploring protein-protein interactions by Weak Affinity Chromatography (WAC) ...Salam Al-Karadaghi
 
OSCamp Kubernetes 2024 | Zero-Touch OS-Infrastruktur für Container und Kubern...
OSCamp Kubernetes 2024 | Zero-Touch OS-Infrastruktur für Container und Kubern...OSCamp Kubernetes 2024 | Zero-Touch OS-Infrastruktur für Container und Kubern...
OSCamp Kubernetes 2024 | Zero-Touch OS-Infrastruktur für Container und Kubern...NETWAYS
 
OSCamp Kubernetes 2024 | A Tester's Guide to CI_CD as an Automated Quality Co...
OSCamp Kubernetes 2024 | A Tester's Guide to CI_CD as an Automated Quality Co...OSCamp Kubernetes 2024 | A Tester's Guide to CI_CD as an Automated Quality Co...
OSCamp Kubernetes 2024 | A Tester's Guide to CI_CD as an Automated Quality Co...NETWAYS
 
NATIONAL ANTHEMS OF AFRICA (National Anthems of Africa)
NATIONAL ANTHEMS OF AFRICA (National Anthems of Africa)NATIONAL ANTHEMS OF AFRICA (National Anthems of Africa)
NATIONAL ANTHEMS OF AFRICA (National Anthems of Africa)Basil Achie
 
Open Source Camp Kubernetes 2024 | Monitoring Kubernetes With Icinga by Eric ...
Open Source Camp Kubernetes 2024 | Monitoring Kubernetes With Icinga by Eric ...Open Source Camp Kubernetes 2024 | Monitoring Kubernetes With Icinga by Eric ...
Open Source Camp Kubernetes 2024 | Monitoring Kubernetes With Icinga by Eric ...NETWAYS
 
Presentation for the Strategic Dialogue on the Future of Agriculture, Brussel...
Presentation for the Strategic Dialogue on the Future of Agriculture, Brussel...Presentation for the Strategic Dialogue on the Future of Agriculture, Brussel...
Presentation for the Strategic Dialogue on the Future of Agriculture, Brussel...Krijn Poppe
 
Open Source Camp Kubernetes 2024 | Running WebAssembly on Kubernetes by Alex ...
Open Source Camp Kubernetes 2024 | Running WebAssembly on Kubernetes by Alex ...Open Source Camp Kubernetes 2024 | Running WebAssembly on Kubernetes by Alex ...
Open Source Camp Kubernetes 2024 | Running WebAssembly on Kubernetes by Alex ...NETWAYS
 
OSCamp Kubernetes 2024 | SRE Challenges in Monolith to Microservices Shift at...
OSCamp Kubernetes 2024 | SRE Challenges in Monolith to Microservices Shift at...OSCamp Kubernetes 2024 | SRE Challenges in Monolith to Microservices Shift at...
OSCamp Kubernetes 2024 | SRE Challenges in Monolith to Microservices Shift at...NETWAYS
 
Genesis part 2 Isaiah Scudder 04-24-2024.pptx
Genesis part 2 Isaiah Scudder 04-24-2024.pptxGenesis part 2 Isaiah Scudder 04-24-2024.pptx
Genesis part 2 Isaiah Scudder 04-24-2024.pptxFamilyWorshipCenterD
 
Philippine History cavite Mutiny Report.ppt
Philippine History cavite Mutiny Report.pptPhilippine History cavite Mutiny Report.ppt
Philippine History cavite Mutiny Report.pptssuser319dad
 
Genshin Impact PPT Template by EaTemp.pptx
Genshin Impact PPT Template by EaTemp.pptxGenshin Impact PPT Template by EaTemp.pptx
Genshin Impact PPT Template by EaTemp.pptxJohnree4
 
Navi Mumbai Call Girls Service Pooja 9892124323 Real Russian Girls Looking Mo...
Navi Mumbai Call Girls Service Pooja 9892124323 Real Russian Girls Looking Mo...Navi Mumbai Call Girls Service Pooja 9892124323 Real Russian Girls Looking Mo...
Navi Mumbai Call Girls Service Pooja 9892124323 Real Russian Girls Looking Mo...Pooja Nehwal
 

Recently uploaded (20)

Call Girls in Rohini Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Rohini Delhi 💯Call Us 🔝8264348440🔝Call Girls in Rohini Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Rohini Delhi 💯Call Us 🔝8264348440🔝
 
The Ten Facts About People With Autism Presentation
The Ten Facts About People With Autism PresentationThe Ten Facts About People With Autism Presentation
The Ten Facts About People With Autism Presentation
 
Gaps, Issues and Challenges in the Implementation of Mother Tongue Based-Mult...
Gaps, Issues and Challenges in the Implementation of Mother Tongue Based-Mult...Gaps, Issues and Challenges in the Implementation of Mother Tongue Based-Mult...
Gaps, Issues and Challenges in the Implementation of Mother Tongue Based-Mult...
 
SBFT Tool Competition 2024 -- Python Test Case Generation Track
SBFT Tool Competition 2024 -- Python Test Case Generation TrackSBFT Tool Competition 2024 -- Python Test Case Generation Track
SBFT Tool Competition 2024 -- Python Test Case Generation Track
 
Open Source Strategy in Logistics 2015_Henrik Hankedvz-d-nl-log-conference.pdf
Open Source Strategy in Logistics 2015_Henrik Hankedvz-d-nl-log-conference.pdfOpen Source Strategy in Logistics 2015_Henrik Hankedvz-d-nl-log-conference.pdf
Open Source Strategy in Logistics 2015_Henrik Hankedvz-d-nl-log-conference.pdf
 
LANDMARKS AND MONUMENTS IN NIGERIA.pptx
LANDMARKS  AND MONUMENTS IN NIGERIA.pptxLANDMARKS  AND MONUMENTS IN NIGERIA.pptx
LANDMARKS AND MONUMENTS IN NIGERIA.pptx
 
Simulation-based Testing of Unmanned Aerial Vehicles with Aerialist
Simulation-based Testing of Unmanned Aerial Vehicles with AerialistSimulation-based Testing of Unmanned Aerial Vehicles with Aerialist
Simulation-based Testing of Unmanned Aerial Vehicles with Aerialist
 
Mathan flower ppt.pptx slide orchids ✨🌸
Mathan flower ppt.pptx slide orchids ✨🌸Mathan flower ppt.pptx slide orchids ✨🌸
Mathan flower ppt.pptx slide orchids ✨🌸
 
Exploring protein-protein interactions by Weak Affinity Chromatography (WAC) ...
Exploring protein-protein interactions by Weak Affinity Chromatography (WAC) ...Exploring protein-protein interactions by Weak Affinity Chromatography (WAC) ...
Exploring protein-protein interactions by Weak Affinity Chromatography (WAC) ...
 
OSCamp Kubernetes 2024 | Zero-Touch OS-Infrastruktur für Container und Kubern...
OSCamp Kubernetes 2024 | Zero-Touch OS-Infrastruktur für Container und Kubern...OSCamp Kubernetes 2024 | Zero-Touch OS-Infrastruktur für Container und Kubern...
OSCamp Kubernetes 2024 | Zero-Touch OS-Infrastruktur für Container und Kubern...
 
OSCamp Kubernetes 2024 | A Tester's Guide to CI_CD as an Automated Quality Co...
OSCamp Kubernetes 2024 | A Tester's Guide to CI_CD as an Automated Quality Co...OSCamp Kubernetes 2024 | A Tester's Guide to CI_CD as an Automated Quality Co...
OSCamp Kubernetes 2024 | A Tester's Guide to CI_CD as an Automated Quality Co...
 
NATIONAL ANTHEMS OF AFRICA (National Anthems of Africa)
NATIONAL ANTHEMS OF AFRICA (National Anthems of Africa)NATIONAL ANTHEMS OF AFRICA (National Anthems of Africa)
NATIONAL ANTHEMS OF AFRICA (National Anthems of Africa)
 
Open Source Camp Kubernetes 2024 | Monitoring Kubernetes With Icinga by Eric ...
Open Source Camp Kubernetes 2024 | Monitoring Kubernetes With Icinga by Eric ...Open Source Camp Kubernetes 2024 | Monitoring Kubernetes With Icinga by Eric ...
Open Source Camp Kubernetes 2024 | Monitoring Kubernetes With Icinga by Eric ...
 
Presentation for the Strategic Dialogue on the Future of Agriculture, Brussel...
Presentation for the Strategic Dialogue on the Future of Agriculture, Brussel...Presentation for the Strategic Dialogue on the Future of Agriculture, Brussel...
Presentation for the Strategic Dialogue on the Future of Agriculture, Brussel...
 
Open Source Camp Kubernetes 2024 | Running WebAssembly on Kubernetes by Alex ...
Open Source Camp Kubernetes 2024 | Running WebAssembly on Kubernetes by Alex ...Open Source Camp Kubernetes 2024 | Running WebAssembly on Kubernetes by Alex ...
Open Source Camp Kubernetes 2024 | Running WebAssembly on Kubernetes by Alex ...
 
OSCamp Kubernetes 2024 | SRE Challenges in Monolith to Microservices Shift at...
OSCamp Kubernetes 2024 | SRE Challenges in Monolith to Microservices Shift at...OSCamp Kubernetes 2024 | SRE Challenges in Monolith to Microservices Shift at...
OSCamp Kubernetes 2024 | SRE Challenges in Monolith to Microservices Shift at...
 
Genesis part 2 Isaiah Scudder 04-24-2024.pptx
Genesis part 2 Isaiah Scudder 04-24-2024.pptxGenesis part 2 Isaiah Scudder 04-24-2024.pptx
Genesis part 2 Isaiah Scudder 04-24-2024.pptx
 
Philippine History cavite Mutiny Report.ppt
Philippine History cavite Mutiny Report.pptPhilippine History cavite Mutiny Report.ppt
Philippine History cavite Mutiny Report.ppt
 
Genshin Impact PPT Template by EaTemp.pptx
Genshin Impact PPT Template by EaTemp.pptxGenshin Impact PPT Template by EaTemp.pptx
Genshin Impact PPT Template by EaTemp.pptx
 
Navi Mumbai Call Girls Service Pooja 9892124323 Real Russian Girls Looking Mo...
Navi Mumbai Call Girls Service Pooja 9892124323 Real Russian Girls Looking Mo...Navi Mumbai Call Girls Service Pooja 9892124323 Real Russian Girls Looking Mo...
Navi Mumbai Call Girls Service Pooja 9892124323 Real Russian Girls Looking Mo...
 

package

  • 1.
  • 2.  Packages are used in Java in order to prevent naming conflicts, to control access, to make searching/locating and usage of classes, interfaces, enumerations and annotations easier.  A Package can be defined as a grouping of related types (classes, interfaces, enumerations and annotations ) providing access protection and namespace management.
  • 3. The Exception Handling in Java is one of the powerful mechanism to handle the runtime errors so that normal flow of the application can be maintained. Types of Java Exceptions  Checked Exception  Unchecked Exception  Error
  • 4.
  • 5.  Checked Exception The classes which directly inherit Throwable class except RuntimeException and Error are known as checked exceptions e.g. IOException, SQLException etc. Checked exceptions are checked at compile-time.  Unchecked Exception The classes which inherit RuntimeException are known as unchecked exceptions e.g. ArithmeticException, NullPointerException, ArrayIndexOutOfBoundsException etc. Unchecked exceptions are not checked at compile-time, but they are checked at runtime.
  • 6.  Error Error is irrecoverable e.g. OutOfMemoryError, VirtualMachineError, AssertionError etc. Example: public class JavaExceptionExample{ public static void main(String args[]){ try{ int data=100/0; } catch(ArithmeticException e){System.out.println(e);} System.out.println("rest of the code..."); } }
  • 7.  Multithreading is a Java feature that allows concurrent execution of two or more parts of a program for maximum utilization of CPU. Each part of such program is called a thread. So, threads are light-weight processes within a process.  Threads can be created by using two mechanisms : 1. Extending the Thread class 2. Implementing the Runnable Interface
  • 8.  Thread creation by extending the Thread class: We create a class that extends the java.lang.Thread class. This class overrides the run() method available in the Thread class. A thread begins its life inside run() method. We create an object of our new class and call start() method to start the execution of a thread. Start() invokes the run() method on the Thread object.  Thread creation by implementing the Runnable Interface We create a new class which implements java.lang.Runnable interface and override run() method. Then we instantiate a Thread object and call start() method on this object.
  • 9. The String object can be created explicitly by using the new keyword and a constructor in the same way as you have created objects previously. For example: The statement String strl =new String("Java"); creates a String object initialized to the value of the string literal "Java" and assigns a reference to string reference variable str. Here, String ("Java") is actually a constructor of the form String (string literal). When this statement is compiled , the Java compiler invokes this constructor and initializes the String object with the string literal enclosed in parentheses which is passed as an argument.
  • 10.  Example: public class StringConstructors { public static void main(String[] args) { char[] charArray ={'H','i',' ','D','I','N','E','S','H'}; byte[] ascii ={65,66,67,68,70,71,73}; String str = "Welcome"; String strl =new String("Java"); String str2 =new String(charArray); String str3 =new String(charArray,3,3); String str4 =new String(ascii); String str5 =new String(ascii,2,3); String str6 =new String(); String str7 =new String(str);
  • 11. System.out.println("str : "+ str); System.out.println("strl : "+ strl); System.out.println("str2 : "+ str2); System.out.println("str3 : "+ str3); System.out.println("str4 : "+ str4); System.out.println("str5 : "+ str5); System.out.println("str6 : "+ str6); System.out.println("str7 : "+ str7); str += " Dinesh Thakur"; System.out.println("str : "+ str); } }
  • 12.  String Handling concept is storing the string data in the main memory (RAM), manipulating the data of the String, retrieving the part of the String etc. String Handling provides a lot of concepts that can be performed on a string such as concatenation of string, comparison of string, find sub string etc.
  • 13.  StringBuffer is a peer class of String that provides much of the functionality of strings. String represents fixed-length, immutable character sequences while StringBuffer represents growable and writable character sequences.
  • 14.  StringBuffer may have characters and substrings inserted in the middle or appended to the end. It will automatically grow to make room for such additions and often has more characters preallocated than are actually needed, to allow room for growth.
  • 15. String Buffer Constructors:  String Buffer()  String Buffer(int size)  String Buffer(String str)  String Buffer(CharSequence chars)
  • 16. StringBuffer Constructors: StringBuffer( ): It reserves room for 16 characters without reallocation. StringBuffer s=new StringBuffer(); StringBuffer( int size): It accepts an integer argument that explicitly sets the size of the buffer. StringBuffer s=new StringBuffer(20);
  • 17. StringBuffer(String str):  It accepts a String argument that sets the initial contents of the StringBuffer object and reserves room for 16 more characters without reallocation.  StringBuffer s = newStringBuffer("GeeksforGeeks");
  • 18.  Methods: Some of the most used methods are: length( ) and capacity( ): The length of a StringBuffer can be found by the length( ) method, while the total allocated capacity() methord.  int length()  int capacity()
  • 19. append( ): It is used to add text at the end of the existence text. Here are a few of its forms:  StringBuffer append(String str)  StringBuffer append(int num) . insert( ): It is used to insert text at the specified index position. These are a few of its forms:  StringBuffer insert(int index, String str)  StringBuffer insert(int index, char ch)
  • 20.  delete( ) and deleteCharAt( ): o It can delete characters within a StringBuffer by using the methods delete( ) and deleteCharAt( ). o The delete( ) method deletes a sequence of characters from the invoking object. o The deleteCharAt( ) method deletes the character at the index specified by loc.  StringBuffer delete(int startIndex, int endIndex)  StringBuffer deleteCharAt(int loc)
  • 21.  replace( ): It can replace one set of characters with another set inside a StringBuffer object by calling replace( ). The substring being replaced is specified by the indexes start Index and endIndex.  StringBuffer replace(int startIndex, int endIndex, String str)
  • 22.  ensureCapacity( ): It is used to increase the capacity of a StringBuffer object. The new capacity will be set to either the value we specify or twice the current capacity plus two (i.e. capacity+2), whichever is larger. Here, capacity specifies the size of the buffer.  void ensureCapacity(int capacity)
  • 23. getchars(): To copy of a substring of a stringbuffer into a array, use the getchars() method().Sourcestart specifies the index of the beginning of the substring, and source end specifies an index of the end substring.  Void getchars(int souceStart, int sourceEnd, char target[], int targetstart)
  • 24.  reverse(): You can reverse the characters within string buffer object using reverse().  String buffer reverse()  substring(): You can obtain a portion of a string buffer by calling substring().  String substring(int starIndex)  String substring(int startIndex, int endIndex)
  • 25.  J2SE 5 adds a new string class to Java’s already powerful string handling capabilities. This new class is called String Builder.  It is identical to String Buffer except for one important difference: it is not synchronized, which means that it is not thread-safe.  The advantage of String Builder is faster performance. However, in cases in which you are using multithreading, you must use String Buffer rather than String Builder.