SlideShare a Scribd company logo
1 of 62
Strings and Strings Manipulation
Contents ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Contents (2) ,[object Object],[object Object],[object Object]
What Is String?
What Is String? ,[object Object],[object Object],[object Object],[object Object],[object Object],String s = "Hello, Java"; s H e l l o , J a v a
java.lang.String ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
java.lang.String  (2) ,[object Object],[object Object],[object Object],[object Object],[object Object],String s = "Hello!"; int len = s. l ength () ; // len = 6 char ch = s .charAt(1) ; // ch = 'e' index = s.charAt(index) = 0 1 2 3 4 5 H e l l o !
Strings – First Example String s = &quot;Stand up, stand up, Balkan superman.&quot;; System.out.printf(&quot;s = amp;quot;%samp;quot;%n&quot;, s); System.out.printf(&quot;s. l ength ()  = %d%n&quot;, s.length()); for (int i = 0; i < s.length(); i++) { System.out.printf(&quot;s[%d] = %c%n&quot;, i, s.charAt(i)); }
Strings – First Example Live Demo
Declaring, Creating, Reading and Printing Creating and Using Strings
Declaring Strings ,[object Object],String str;
Creating Strings ,[object Object],[object Object],[object Object],[object Object],[object Object]
Creating Strings (2) ,[object Object],[object Object],[object Object],[object Object],S tring s;  // s  is  equal to null St ring s  = &quot;I am string literal!&quot;; S tring s 2 = s; String s = &quot;I'm &quot; + 42 + &quot; years old.&quot;;
Reading And Printing Strings ,[object Object],[object Object],String s = input.nextLine(); ,[object Object],[object Object],System.out.print(&quot;Please enter your name: &quot;);  String name = input.nextLine(); System.out.printf(&quot;Hello, %s!%n&quot;, name);
Live Demo Reading and Printing Strings
Manipulating Strings Comparing, Concatenating, Searching, Extracting Substrings, Splitting
Comparing Strings ,[object Object],[object Object],[object Object],[object Object],int result = str1.compareToIgnoreCase(str2); // result == 0 if str1 equals str2 // result < 0 if str1 if before str2 // result > 0 if str1 if after str2 str1.compareTo(str2);
Comparing Strings (2) ,[object Object],[object Object],[object Object],[object Object],if (str1.equalsIgnoreCase(str2)){ … } if (str1.equals(str2)){ … }
Comparing Strings (3) ,[object Object],[object Object],[object Object],String str1 = new String(&quot;Hello&quot;); String str2 = str1; System.out.println((str1==str2)); // true String str1 = &quot;Hello&quot;; String str2 = &quot;Hello&quot;; System.out.println((str1==str2)); // true !!! String str1 = new String(&quot;Hello&quot;); String str2 = new String(&quot;Hello&quot;); System.out.println((str1==str2)); // This is false !
Comparing Strings – Example  ,[object Object],String[] towns = {&quot;Sofia&quot;, &quot;Varna&quot;, &quot;Plovdiv&quot;, &quot;Pleven&quot;, &quot;Bourgas&quot;, &quot;Rousse&quot;, &quot;Yambol&quot;}; String firstTown = towns[0]; for (int i=1; i<towns. l ength; i++) { String currentTown = towns[i]; if (currentTown.compareTo(firstTown) < 0) { firstTown = currentTown; } } System.out.println(&quot;First town: &quot; + firstTown);
Comparing Strings Live Demo
Concatenating Strings ,[object Object],[object Object],[object Object],[object Object],S tring str =  str1. c oncat(str2);   String str = str1 + str2 + str3; String str += str1; S tring  n ame = &quot; Peter &quot;; int   age  =  22 ; S tring  s  =  name  + &quot; &quot; +  age ;  //  οƒ   &quot;Peter 22&quot;
Concatenating Strings – Example String firstName = &quot;Svetlin&quot;; String lastName = &quot;Nakov&quot;; String fullName = firstName + &quot; &quot; + lastName; System.out.println(fullName); int age = 2 6 ; String nameAndAge = &quot;Name: &quot; + fullName +    &quot;Age: &quot; + age; System.out.println(nameAndAge); // Name: Svetlin Nakov // Age: 2 6
Concatenating Strings Live Demo
Searching Strings ,[object Object],[object Object],[object Object],[object Object],[object Object],i ndexOf( S tring str) i ndexOf( S tring str, int  from Index) l astIndexOf( S tring) lastIndexOf(String, int fromIndex)
Searching Strings – Example String str = &quot;Java Programming Course&quot;; int index = str.indexOf(&quot;Java&quot;); // index = 0 index = str.indexOf(&quot;Course&quot;); // index = 17 index = str.indexOf(&quot;COURSE&quot;); // index = -1 // indexOf is case sensetive. -1 means not found index = str.indexOf(&quot;ram&quot;); // index = 9 index = str.indexOf(&quot;r&quot;); // index = 6 index = str.indexOf(&quot;r&quot;, 7); // index = 9 index = str.indexOf(&quot;r&quot;, 10); // index = 20 i = s.charAt(i) = 0 1 2 3 4 5 6 7 8 9 10 11 12 … J a v a P r o g r a m m …
Searching Strings Live Demo
Extracting Substrings ,[object Object],[object Object],[object Object],[object Object],S tring filename = &quot;C: ics ila2005.jpg&quot;; S tring name = filename. s ub s tring(8,  16 ); // name is Rila2005 S tring filename = &quot;C: ics ummer2005.jpg&quot;; S tring nameAndExtension = filename. s ub s tring(8); // nameAndExtension is Rila2005 .jpg 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 C :   P i c s  R i l a 2 0 0 5 . j p g
Extracting Substrings Live Demo
Splitting Strings ,[object Object],[object Object],[object Object],String[] split(String regex) String[] parts = &quot;Ivan; Petar,Gosho&quot;.split(&quot;[;,]&quot;); // this wil separate the stirng into three parts // &quot;Ivan&quot;, &quot; Petar&quot; and &quot;Gosho&quot;
Splitting Strings - Example String listOfBeers =  &quot;Amstel, Zagorka, Tuborg, Becks.&quot;; String[] beers = listOfBeers.split(&quot;[ ,.]&quot;); System.out.println(&quot;Available beers are:&quot;); for (String beer : beers) { if (!&quot;&quot;.equalsIgnoreCase(beer)) { System.out.println(beer); } }
Splitting Strings Live Demo
Other String Operations Replacing Substrings, Changing Character Casing, Trimming
Replacing Substrings ,[object Object],[object Object],String cocktail = &quot;Vodka + Martini + Cherry&quot;; String replaced = cocktail.replace(&quot;+&quot;, &quot;and&quot;); // Vodka and Martini and Cherry
Changing Character Casing ,[object Object],[object Object],S tring alpha = &quot;aBcDeFg&quot;; S tring lowerAlpha = alpha. t oLower Case ();   //   abcdefg System.out.println(lowerAlpha); S tring alpha = &quot;aBcDeFg&quot;; S tring upper A lpha = alpha. t oUpper Case ();   //  ABCDEFG System.out.println(upperAlpha);
Trimming White Space ,[object Object],String s = &quot;  example of white space  &quot;; String clean = s.trim(); System.out.println(clean);
Other String Operations Live Demo
Building and Modifying Strings Using  StringBuilder  C lass
Constructing Strings ,[object Object],[object Object],[object Object],[object Object],public  static s tring  d upChar(char ch, int count){ S tring result = &quot;&quot;; for (int i=0; i<count; i++) result += ch; return result; } Bad practice. Avoid this!
Changing the Contents of a String –  StringBuilder ,[object Object],[object Object],public static String  r everseIt(String s) { StringBuilder sb = new StringBuilder(); for (int i = s.length()-1; i >= 0; i--) sb.append(s.charAt(i)); return sb.ToString(); }
The  StringBuilde r Class ,[object Object],[object Object],StringBuilder : length() = 11 capacity() = 15 used buffer (length()) unused buffer Capacity H e l l o , J a v a !
The  StringBuilde r Class (2) ,[object Object],[object Object],[object Object],[object Object],[object Object]
The  StringBuilde r Class (3) ,[object Object],[object Object],[object Object],[object Object],[object Object]
StringBuilder  – Example ,[object Object],public static String extractCapitals(String s) { StringBuilder result = new StringBuilder(); for (int i = 0; i < s.length(); i++) { char ch = s.charAt(i); if (Character.isUpperCase(ch)) { result.append(ch); } } return result.toString(); }
How the  +  Operator Does String Concatenations? ,[object Object],[object Object],[object Object],[object Object],String result = str1 + str2; StringBuffer sb = new StringBuffer(); sb. a ppend(str1); sb. a ppend(str2); S tring result = sb. t oString();
Using  StringBuilder Live Demo
Formatting Strings Using  t oString()  and  String. f ormat()
Method  toString() ,[object Object],[object Object],[object Object]
Method  String.format() ,[object Object],[object Object],[object Object],String template = &quot;If I were %s, I would %s.&quot;; String sentence1 = String.format( template, &quot;developer&quot;, &quot;know Java&quot;); System.out.println(sentence1); // If I were developer, I would know  Java . String sentence2 = String.format( template, &quot;elephant&quot;, &quot;weigh 4500 kg&quot;); System.out.println(sentence2); // If I were elephant, I would weigh 4500 kg.
Formatting Dates ,[object Object],[object Object],[object Object],[object Object],[object Object],Date  now  = (new GregorianCalendar()).getTime(); System.out.printf(&quot;Now is &quot; +  &quot;%1$td.%1$tm.%1$tY %1$tH:%1$tM:%1$tS&quot;,  now ); // Now is 23.05.2006 21:09:32
Formatting Strings Live Demo
Summary ,[object Object],[object Object],[object Object],[object Object],[object Object]
Summary (2) ,[object Object],[object Object]
Exercises ,[object Object],[object Object]
Exercises (2) ,[object Object],[object Object],[object Object],We are living in a yellow submarine. We don't have anything else. Inside the submarine is very tight. So we are drinking all the day. We will move out of it in 5 days.
Exercises (3) ,[object Object],[object Object],We are living in a  <upcase> yellow submarine</upcase>. We don't have <upcase>anything</upcase>  else . We are living in a  YELLOW SUBMARINE . We don't have  ANYTHING  else.
Exercises (4) ,[object Object],[object Object],[protocol]://[server]/[resource]
Exercises (5) ,[object Object],[object Object],[object Object],We are living in a yellow submarine. We don't have anything else. Inside the submarine is very tight. So we are drinking all the day. We will move out of it in 5 days. We are living in a yellow submarine. We will move out of it in 5 days.
Exercises (6) ,[object Object],[object Object],[object Object],Microsoft announced its next generation Java compiler today. It uses advanced parser and special optimizer for the Microsoft JVM. ********* announced its next generation **** compiler today. It uses advanced parser and special optimizer for the ********* ***.
Exercises (7) ,[object Object],[object Object],[object Object]
Exercises (8) ,[object Object],[object Object]
Exercises (9) ,[object Object]

More Related Content

What's hot

Java Stack Data Structure.pptx
Java Stack Data Structure.pptxJava Stack Data Structure.pptx
Java Stack Data Structure.pptxvishal choudhary
Β 
Data structure and algorithm with java implementation by obaid kakar
Data structure and algorithm with java implementation by obaid kakarData structure and algorithm with java implementation by obaid kakar
Data structure and algorithm with java implementation by obaid kakarObaid Kakar
Β 
Java String
Java StringJava String
Java StringJava2Blog
Β 
Java arrays
Java arraysJava arrays
Java arraysKuppusamy P
Β 
Java Script ppt
Java Script pptJava Script ppt
Java Script pptPriya Goyal
Β 
Java programming-examples
Java programming-examplesJava programming-examples
Java programming-examplesMumbai Academisc
Β 
TypeScript VS JavaScript.pptx
TypeScript VS JavaScript.pptxTypeScript VS JavaScript.pptx
TypeScript VS JavaScript.pptxAlbiorix Technology
Β 
9. Input Output in java
9. Input Output in java9. Input Output in java
9. Input Output in javaNilesh Dalvi
Β 
Introduction to Java Scripting
Introduction to Java ScriptingIntroduction to Java Scripting
Introduction to Java Scriptingfantasticdigitaltools
Β 
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
Β 
Core java concepts
Core java  conceptsCore java  concepts
Core java conceptsRam132
Β 
Packages,static,this keyword in java
Packages,static,this keyword in javaPackages,static,this keyword in java
Packages,static,this keyword in javaVishnu Suresh
Β 
Java script final presentation
Java script final presentationJava script final presentation
Java script final presentationAdhoura Academy
Β 
Multi-threaded Programming in JAVA
Multi-threaded Programming in JAVAMulti-threaded Programming in JAVA
Multi-threaded Programming in JAVAVikram Kalyani
Β 
Streams in Java 8
Streams in Java 8Streams in Java 8
Streams in Java 8Tobias Coetzee
Β 
String C Programming
String C ProgrammingString C Programming
String C ProgrammingPrionto Abdullah
Β 

What's hot (20)

Java Stack Data Structure.pptx
Java Stack Data Structure.pptxJava Stack Data Structure.pptx
Java Stack Data Structure.pptx
Β 
Data structure and algorithm with java implementation by obaid kakar
Data structure and algorithm with java implementation by obaid kakarData structure and algorithm with java implementation by obaid kakar
Data structure and algorithm with java implementation by obaid kakar
Β 
Java String
Java StringJava String
Java String
Β 
Array in c#
Array in c#Array in c#
Array in c#
Β 
Java arrays
Java arraysJava arrays
Java arrays
Β 
Java Script ppt
Java Script pptJava Script ppt
Java Script ppt
Β 
Java programming-examples
Java programming-examplesJava programming-examples
Java programming-examples
Β 
TypeScript VS JavaScript.pptx
TypeScript VS JavaScript.pptxTypeScript VS JavaScript.pptx
TypeScript VS JavaScript.pptx
Β 
9. Input Output in java
9. Input Output in java9. Input Output in java
9. Input Output in java
Β 
Introduction to Java Scripting
Introduction to Java ScriptingIntroduction to Java Scripting
Introduction to Java Scripting
Β 
String Builder & String Buffer (Java Programming)
String Builder & String Buffer (Java Programming)String Builder & String Buffer (Java Programming)
String Builder & String Buffer (Java Programming)
Β 
Core java concepts
Core java  conceptsCore java  concepts
Core java concepts
Β 
Packages,static,this keyword in java
Packages,static,this keyword in javaPackages,static,this keyword in java
Packages,static,this keyword in java
Β 
Java script final presentation
Java script final presentationJava script final presentation
Java script final presentation
Β 
Java constructors
Java constructorsJava constructors
Java constructors
Β 
Multi-threaded Programming in JAVA
Multi-threaded Programming in JAVAMulti-threaded Programming in JAVA
Multi-threaded Programming in JAVA
Β 
Java Strings
Java StringsJava Strings
Java Strings
Β 
Streams in Java 8
Streams in Java 8Streams in Java 8
Streams in Java 8
Β 
String C Programming
String C ProgrammingString C Programming
String C Programming
Β 
C++ string
C++ stringC++ string
C++ string
Β 

Viewers also liked

C# string concatenations in unity (Updated 2014/7/11)
C# string concatenations in unity (Updated 2014/7/11)C# string concatenations in unity (Updated 2014/7/11)
C# string concatenations in unity (Updated 2014/7/11)Sindharta Tanuwijaya
Β 
Php String And Regular Expressions
Php String  And Regular ExpressionsPhp String  And Regular Expressions
Php String And Regular Expressionsmussawir20
Β 
Object-oriented Programming-with C#
Object-oriented Programming-with C#Object-oriented Programming-with C#
Object-oriented Programming-with C#Doncho Minkov
Β 
Regular Expressions
Regular ExpressionsRegular Expressions
Regular ExpressionsSatya Narayana
Β 
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
Β 
Java servlet life cycle - methods ppt
Java servlet life cycle - methods pptJava servlet life cycle - methods ppt
Java servlet life cycle - methods pptkamal kotecha
Β 

Viewers also liked (10)

C# String
C# StringC# String
C# String
Β 
C# Strings
C# StringsC# Strings
C# Strings
Β 
C# string concatenations in unity (Updated 2014/7/11)
C# string concatenations in unity (Updated 2014/7/11)C# string concatenations in unity (Updated 2014/7/11)
C# string concatenations in unity (Updated 2014/7/11)
Β 
Php String And Regular Expressions
Php String  And Regular ExpressionsPhp String  And Regular Expressions
Php String And Regular Expressions
Β 
Servlets
ServletsServlets
Servlets
Β 
Object-oriented Programming-with C#
Object-oriented Programming-with C#Object-oriented Programming-with C#
Object-oriented Programming-with C#
Β 
Oops concept on c#
Oops concept on c#Oops concept on c#
Oops concept on c#
Β 
Regular Expressions
Regular ExpressionsRegular Expressions
Regular Expressions
Β 
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
Β 
Java servlet life cycle - methods ppt
Java servlet life cycle - methods pptJava servlet life cycle - methods ppt
Java servlet life cycle - methods ppt
Β 

Similar to Strings v.1.1

M C6java7
M C6java7M C6java7
M C6java7mbruggen
Β 
String and string manipulation x
String and string manipulation xString and string manipulation x
String and string manipulation xShahjahan Samoon
Β 
String and string manipulation
String and string manipulationString and string manipulation
String and string manipulationShahjahan Samoon
Β 
Csphtp1 15
Csphtp1 15Csphtp1 15
Csphtp1 15HUST
Β 
Chapter 9 - Characters and Strings
Chapter 9 - Characters and StringsChapter 9 - Characters and Strings
Chapter 9 - Characters and StringsEduardo Bergavera
Β 
Java căn bản - Chapter9
Java căn bản - Chapter9Java căn bản - Chapter9
Java căn bản - Chapter9Vince Vo
Β 
16 strings-and-text-processing-120712074956-phpapp02
16 strings-and-text-processing-120712074956-phpapp0216 strings-and-text-processing-120712074956-phpapp02
16 strings-and-text-processing-120712074956-phpapp02Abdul Samee
Β 
Regular Expression
Regular ExpressionRegular Expression
Regular ExpressionBharat17485
Β 
Week6_P_String.pptx
Week6_P_String.pptxWeek6_P_String.pptx
Week6_P_String.pptxOluwafolakeOjo
Β 
13 Strings and Text Processing
13 Strings and Text Processing13 Strings and Text Processing
13 Strings and Text ProcessingIntro C# Book
Β 
[ITP - Lecture 17] Strings in C/C++
[ITP - Lecture 17] Strings in C/C++[ITP - Lecture 17] Strings in C/C++
[ITP - Lecture 17] Strings in C/C++Muhammad Hammad Waseem
Β 
0-Slot21-22-Strings.pdf
0-Slot21-22-Strings.pdf0-Slot21-22-Strings.pdf
0-Slot21-22-Strings.pdfssusere19c741
Β 
Handling of character strings C programming
Handling of character strings C programmingHandling of character strings C programming
Handling of character strings C programmingAppili Vamsi Krishna
Β 
Strings in Python
Strings in PythonStrings in Python
Strings in Pythonnitamhaske
Β 
pps unit 3.pptx
pps unit 3.pptxpps unit 3.pptx
pps unit 3.pptxmathesh0303
Β 
Input And Output
 Input And Output Input And Output
Input And OutputGhaffar Khan
Β 

Similar to Strings v.1.1 (20)

M C6java7
M C6java7M C6java7
M C6java7
Β 
String and string manipulation x
String and string manipulation xString and string manipulation x
String and string manipulation x
Β 
String and string manipulation
String and string manipulationString and string manipulation
String and string manipulation
Β 
Csphtp1 15
Csphtp1 15Csphtp1 15
Csphtp1 15
Β 
Chapter 9 - Characters and Strings
Chapter 9 - Characters and StringsChapter 9 - Characters and Strings
Chapter 9 - Characters and Strings
Β 
Java căn bản - Chapter9
Java căn bản - Chapter9Java căn bản - Chapter9
Java căn bản - Chapter9
Β 
16 strings-and-text-processing-120712074956-phpapp02
16 strings-and-text-processing-120712074956-phpapp0216 strings-and-text-processing-120712074956-phpapp02
16 strings-and-text-processing-120712074956-phpapp02
Β 
Regular Expression
Regular ExpressionRegular Expression
Regular Expression
Β 
Ch09
Ch09Ch09
Ch09
Β 
Team 1
Team 1Team 1
Team 1
Β 
Week6_P_String.pptx
Week6_P_String.pptxWeek6_P_String.pptx
Week6_P_String.pptx
Β 
String notes
String notesString notes
String notes
Β 
13 Strings and Text Processing
13 Strings and Text Processing13 Strings and Text Processing
13 Strings and Text Processing
Β 
[ITP - Lecture 17] Strings in C/C++
[ITP - Lecture 17] Strings in C/C++[ITP - Lecture 17] Strings in C/C++
[ITP - Lecture 17] Strings in C/C++
Β 
0-Slot21-22-Strings.pdf
0-Slot21-22-Strings.pdf0-Slot21-22-Strings.pdf
0-Slot21-22-Strings.pdf
Β 
Handling of character strings C programming
Handling of character strings C programmingHandling of character strings C programming
Handling of character strings C programming
Β 
Strings in Python
Strings in PythonStrings in Python
Strings in Python
Β 
pps unit 3.pptx
pps unit 3.pptxpps unit 3.pptx
pps unit 3.pptx
Β 
14 strings
14 strings14 strings
14 strings
Β 
Input And Output
 Input And Output Input And Output
Input And Output
Β 

More from BG Java EE Course

More from BG Java EE Course (20)

Rich faces
Rich facesRich faces
Rich faces
Β 
JSP Custom Tags
JSP Custom TagsJSP Custom Tags
JSP Custom Tags
Β 
Java Server Faces (JSF) - advanced
Java Server Faces (JSF) - advancedJava Server Faces (JSF) - advanced
Java Server Faces (JSF) - advanced
Β 
Java Server Faces (JSF) - Basics
Java Server Faces (JSF) - BasicsJava Server Faces (JSF) - Basics
Java Server Faces (JSF) - Basics
Β 
JSTL
JSTLJSTL
JSTL
Β 
Unified Expression Language
Unified Expression LanguageUnified Expression Language
Unified Expression Language
Β 
Java Server Pages
Java Server PagesJava Server Pages
Java Server Pages
Β 
Web Applications and Deployment
Web Applications and DeploymentWeb Applications and Deployment
Web Applications and Deployment
Β 
Java Servlets
Java ServletsJava Servlets
Java Servlets
Β 
CSS
CSSCSS
CSS
Β 
HTML: Tables and Forms
HTML: Tables and FormsHTML: Tables and Forms
HTML: Tables and Forms
Β 
HTML Fundamentals
HTML FundamentalsHTML Fundamentals
HTML Fundamentals
Β 
WWW and HTTP
WWW and HTTPWWW and HTTP
WWW and HTTP
Β 
JavaScript and jQuery Fundamentals
JavaScript and jQuery FundamentalsJavaScript and jQuery Fundamentals
JavaScript and jQuery Fundamentals
Β 
Creating Web Sites with HTML and CSS
Creating Web Sites with HTML and CSSCreating Web Sites with HTML and CSS
Creating Web Sites with HTML and CSS
Β 
Processing XML with Java
Processing XML with JavaProcessing XML with Java
Processing XML with Java
Β 
Introduction to XML
Introduction to XMLIntroduction to XML
Introduction to XML
Β 
Data Access with JDBC
Data Access with JDBCData Access with JDBC
Data Access with JDBC
Β 
Introduction to-sql
Introduction to-sqlIntroduction to-sql
Introduction to-sql
Β 
Introduction to-RDBMS-systems
Introduction to-RDBMS-systemsIntroduction to-RDBMS-systems
Introduction to-RDBMS-systems
Β 

Recently uploaded

Call Girl Service Belur - 7001035870 with real photos and phone numbers
Call Girl Service Belur - 7001035870 with real photos and phone numbersCall Girl Service Belur - 7001035870 with real photos and phone numbers
Call Girl Service Belur - 7001035870 with real photos and phone numbersanamikaraghav4
Β 
College Call Girls New Alipore - For 7001035870 Cheap & Best with original Ph...
College Call Girls New Alipore - For 7001035870 Cheap & Best with original Ph...College Call Girls New Alipore - For 7001035870 Cheap & Best with original Ph...
College Call Girls New Alipore - For 7001035870 Cheap & Best with original Ph...anamikaraghav4
Β 
Call Girl Nashik Amaira 7001305949 Independent Escort Service Nashik
Call Girl Nashik Amaira 7001305949 Independent Escort Service NashikCall Girl Nashik Amaira 7001305949 Independent Escort Service Nashik
Call Girl Nashik Amaira 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
Β 
↑Top Model (Kolkata) Call Girls Salt Lake ⟟ 8250192130 ⟟ High Class Call Girl...
↑Top Model (Kolkata) Call Girls Salt Lake ⟟ 8250192130 ⟟ High Class Call Girl...↑Top Model (Kolkata) Call Girls Salt Lake ⟟ 8250192130 ⟟ High Class Call Girl...
↑Top Model (Kolkata) Call Girls Salt Lake ⟟ 8250192130 ⟟ High Class Call Girl...noor ahmed
Β 
Top Rated Kolkata Call Girls Khardah ⟟ 6297143586 ⟟ Call Me For Genuine Sex S...
Top Rated Kolkata Call Girls Khardah ⟟ 6297143586 ⟟ Call Me For Genuine Sex S...Top Rated Kolkata Call Girls Khardah ⟟ 6297143586 ⟟ Call Me For Genuine Sex S...
Top Rated Kolkata Call Girls Khardah ⟟ 6297143586 ⟟ Call Me For Genuine Sex S...ritikasharma
Β 
Call Girls Manjri Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Manjri Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Manjri Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Manjri Call Me 7737669865 Budget Friendly No Advance Bookingroncy bisnoi
Β 
Model Call Girls In Pazhavanthangal WhatsApp Booking 7427069034 call girl ser...
Model Call Girls In Pazhavanthangal WhatsApp Booking 7427069034 call girl ser...Model Call Girls In Pazhavanthangal WhatsApp Booking 7427069034 call girl ser...
Model Call Girls In Pazhavanthangal WhatsApp Booking 7427069034 call girl ser... Shivani Pandey
Β 
Call Girl Nashik Saloni 7001305949 Independent Escort Service Nashik
Call Girl Nashik Saloni 7001305949 Independent Escort Service NashikCall Girl Nashik Saloni 7001305949 Independent Escort Service Nashik
Call Girl Nashik Saloni 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
Β 
Science City Kolkata ( Call Girls ) Kolkata βœ” 6297143586 βœ” Hot Model With Sex...
Science City Kolkata ( Call Girls ) Kolkata βœ” 6297143586 βœ” Hot Model With Sex...Science City Kolkata ( Call Girls ) Kolkata βœ” 6297143586 βœ” Hot Model With Sex...
Science City Kolkata ( Call Girls ) Kolkata βœ” 6297143586 βœ” Hot Model With Sex...rahim quresi
Β 
Call Girls Nashik Gayatri 7001305949 Independent Escort Service Nashik
Call Girls Nashik Gayatri 7001305949 Independent Escort Service NashikCall Girls Nashik Gayatri 7001305949 Independent Escort Service Nashik
Call Girls Nashik Gayatri 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
Β 
2k Shot Call girls Laxmi Nagar Delhi 9205541914
2k Shot Call girls Laxmi Nagar Delhi 92055419142k Shot Call girls Laxmi Nagar Delhi 9205541914
2k Shot Call girls Laxmi Nagar Delhi 9205541914Delhi Call girls
Β 
πŸ‘™ Kolkata Call Girls Sonagachi πŸ’«πŸ’«7001035870 Model escorts Service
πŸ‘™  Kolkata Call Girls Sonagachi πŸ’«πŸ’«7001035870 Model escorts ServiceπŸ‘™  Kolkata Call Girls Sonagachi πŸ’«πŸ’«7001035870 Model escorts Service
πŸ‘™ Kolkata Call Girls Sonagachi πŸ’«πŸ’«7001035870 Model escorts Serviceanamikaraghav4
Β 
↑Top Model (Kolkata) Call Girls Howrah ⟟ 8250192130 ⟟ High Class Call Girl In...
↑Top Model (Kolkata) Call Girls Howrah ⟟ 8250192130 ⟟ High Class Call Girl In...↑Top Model (Kolkata) Call Girls Howrah ⟟ 8250192130 ⟟ High Class Call Girl In...
↑Top Model (Kolkata) Call Girls Howrah ⟟ 8250192130 ⟟ High Class Call Girl In...noor ahmed
Β 
↑Top Model (Kolkata) Call Girls Sonagachi ⟟ 8250192130 ⟟ High Class Call Girl...
↑Top Model (Kolkata) Call Girls Sonagachi ⟟ 8250192130 ⟟ High Class Call Girl...↑Top Model (Kolkata) Call Girls Sonagachi ⟟ 8250192130 ⟟ High Class Call Girl...
↑Top Model (Kolkata) Call Girls Sonagachi ⟟ 8250192130 ⟟ High Class Call Girl...noor ahmed
Β 
Book Sex Workers Available Kolkata Call Girls Service Airport Kolkata βœ” 62971...
Book Sex Workers Available Kolkata Call Girls Service Airport Kolkata βœ” 62971...Book Sex Workers Available Kolkata Call Girls Service Airport Kolkata βœ” 62971...
Book Sex Workers Available Kolkata Call Girls Service Airport Kolkata βœ” 62971...ritikasharma
Β 
Almora call girls πŸ“ž 8617697112 At Low Cost Cash Payment Booking
Almora call girls πŸ“ž 8617697112 At Low Cost Cash Payment BookingAlmora call girls πŸ“ž 8617697112 At Low Cost Cash Payment Booking
Almora call girls πŸ“ž 8617697112 At Low Cost Cash Payment BookingNitya salvi
Β 
Model Call Girls In Velappanchavadi WhatsApp Booking 7427069034 call girl ser...
Model Call Girls In Velappanchavadi WhatsApp Booking 7427069034 call girl ser...Model Call Girls In Velappanchavadi WhatsApp Booking 7427069034 call girl ser...
Model Call Girls In Velappanchavadi WhatsApp Booking 7427069034 call girl ser... Shivani Pandey
Β 

Recently uploaded (20)

Call Girl Service Belur - 7001035870 with real photos and phone numbers
Call Girl Service Belur - 7001035870 with real photos and phone numbersCall Girl Service Belur - 7001035870 with real photos and phone numbers
Call Girl Service Belur - 7001035870 with real photos and phone numbers
Β 
College Call Girls New Alipore - For 7001035870 Cheap & Best with original Ph...
College Call Girls New Alipore - For 7001035870 Cheap & Best with original Ph...College Call Girls New Alipore - For 7001035870 Cheap & Best with original Ph...
College Call Girls New Alipore - For 7001035870 Cheap & Best with original Ph...
Β 
Call Girls South Avenue Delhi WhatsApp Number 9711199171
Call Girls South Avenue Delhi WhatsApp Number 9711199171Call Girls South Avenue Delhi WhatsApp Number 9711199171
Call Girls South Avenue Delhi WhatsApp Number 9711199171
Β 
Call Girl Nashik Amaira 7001305949 Independent Escort Service Nashik
Call Girl Nashik Amaira 7001305949 Independent Escort Service NashikCall Girl Nashik Amaira 7001305949 Independent Escort Service Nashik
Call Girl Nashik Amaira 7001305949 Independent Escort Service Nashik
Β 
↑Top Model (Kolkata) Call Girls Salt Lake ⟟ 8250192130 ⟟ High Class Call Girl...
↑Top Model (Kolkata) Call Girls Salt Lake ⟟ 8250192130 ⟟ High Class Call Girl...↑Top Model (Kolkata) Call Girls Salt Lake ⟟ 8250192130 ⟟ High Class Call Girl...
↑Top Model (Kolkata) Call Girls Salt Lake ⟟ 8250192130 ⟟ High Class Call Girl...
Β 
Top Rated Kolkata Call Girls Khardah ⟟ 6297143586 ⟟ Call Me For Genuine Sex S...
Top Rated Kolkata Call Girls Khardah ⟟ 6297143586 ⟟ Call Me For Genuine Sex S...Top Rated Kolkata Call Girls Khardah ⟟ 6297143586 ⟟ Call Me For Genuine Sex S...
Top Rated Kolkata Call Girls Khardah ⟟ 6297143586 ⟟ Call Me For Genuine Sex S...
Β 
Call Girls Manjri Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Manjri Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Manjri Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Manjri Call Me 7737669865 Budget Friendly No Advance Booking
Β 
Model Call Girls In Pazhavanthangal WhatsApp Booking 7427069034 call girl ser...
Model Call Girls In Pazhavanthangal WhatsApp Booking 7427069034 call girl ser...Model Call Girls In Pazhavanthangal WhatsApp Booking 7427069034 call girl ser...
Model Call Girls In Pazhavanthangal WhatsApp Booking 7427069034 call girl ser...
Β 
Call Girl Nashik Saloni 7001305949 Independent Escort Service Nashik
Call Girl Nashik Saloni 7001305949 Independent Escort Service NashikCall Girl Nashik Saloni 7001305949 Independent Escort Service Nashik
Call Girl Nashik Saloni 7001305949 Independent Escort Service Nashik
Β 
Call Girls Chirag Delhi Delhi WhatsApp Number 9711199171
Call Girls Chirag Delhi Delhi WhatsApp Number 9711199171Call Girls Chirag Delhi Delhi WhatsApp Number 9711199171
Call Girls Chirag Delhi Delhi WhatsApp Number 9711199171
Β 
Goa Call Girls 9316020077 Call Girls In Goa By Russian Call Girl in goa
Goa Call Girls 9316020077 Call Girls  In Goa By Russian Call Girl in goaGoa Call Girls 9316020077 Call Girls  In Goa By Russian Call Girl in goa
Goa Call Girls 9316020077 Call Girls In Goa By Russian Call Girl in goa
Β 
Science City Kolkata ( Call Girls ) Kolkata βœ” 6297143586 βœ” Hot Model With Sex...
Science City Kolkata ( Call Girls ) Kolkata βœ” 6297143586 βœ” Hot Model With Sex...Science City Kolkata ( Call Girls ) Kolkata βœ” 6297143586 βœ” Hot Model With Sex...
Science City Kolkata ( Call Girls ) Kolkata βœ” 6297143586 βœ” Hot Model With Sex...
Β 
Call Girls Nashik Gayatri 7001305949 Independent Escort Service Nashik
Call Girls Nashik Gayatri 7001305949 Independent Escort Service NashikCall Girls Nashik Gayatri 7001305949 Independent Escort Service Nashik
Call Girls Nashik Gayatri 7001305949 Independent Escort Service Nashik
Β 
2k Shot Call girls Laxmi Nagar Delhi 9205541914
2k Shot Call girls Laxmi Nagar Delhi 92055419142k Shot Call girls Laxmi Nagar Delhi 9205541914
2k Shot Call girls Laxmi Nagar Delhi 9205541914
Β 
πŸ‘™ Kolkata Call Girls Sonagachi πŸ’«πŸ’«7001035870 Model escorts Service
πŸ‘™  Kolkata Call Girls Sonagachi πŸ’«πŸ’«7001035870 Model escorts ServiceπŸ‘™  Kolkata Call Girls Sonagachi πŸ’«πŸ’«7001035870 Model escorts Service
πŸ‘™ Kolkata Call Girls Sonagachi πŸ’«πŸ’«7001035870 Model escorts Service
Β 
↑Top Model (Kolkata) Call Girls Howrah ⟟ 8250192130 ⟟ High Class Call Girl In...
↑Top Model (Kolkata) Call Girls Howrah ⟟ 8250192130 ⟟ High Class Call Girl In...↑Top Model (Kolkata) Call Girls Howrah ⟟ 8250192130 ⟟ High Class Call Girl In...
↑Top Model (Kolkata) Call Girls Howrah ⟟ 8250192130 ⟟ High Class Call Girl In...
Β 
↑Top Model (Kolkata) Call Girls Sonagachi ⟟ 8250192130 ⟟ High Class Call Girl...
↑Top Model (Kolkata) Call Girls Sonagachi ⟟ 8250192130 ⟟ High Class Call Girl...↑Top Model (Kolkata) Call Girls Sonagachi ⟟ 8250192130 ⟟ High Class Call Girl...
↑Top Model (Kolkata) Call Girls Sonagachi ⟟ 8250192130 ⟟ High Class Call Girl...
Β 
Book Sex Workers Available Kolkata Call Girls Service Airport Kolkata βœ” 62971...
Book Sex Workers Available Kolkata Call Girls Service Airport Kolkata βœ” 62971...Book Sex Workers Available Kolkata Call Girls Service Airport Kolkata βœ” 62971...
Book Sex Workers Available Kolkata Call Girls Service Airport Kolkata βœ” 62971...
Β 
Almora call girls πŸ“ž 8617697112 At Low Cost Cash Payment Booking
Almora call girls πŸ“ž 8617697112 At Low Cost Cash Payment BookingAlmora call girls πŸ“ž 8617697112 At Low Cost Cash Payment Booking
Almora call girls πŸ“ž 8617697112 At Low Cost Cash Payment Booking
Β 
Model Call Girls In Velappanchavadi WhatsApp Booking 7427069034 call girl ser...
Model Call Girls In Velappanchavadi WhatsApp Booking 7427069034 call girl ser...Model Call Girls In Velappanchavadi WhatsApp Booking 7427069034 call girl ser...
Model Call Girls In Velappanchavadi WhatsApp Booking 7427069034 call girl ser...
Β 

Strings v.1.1

  • 1. Strings and Strings Manipulation
  • 2.
  • 3.
  • 5.
  • 6.
  • 7.
  • 8. Strings – First Example String s = &quot;Stand up, stand up, Balkan superman.&quot;; System.out.printf(&quot;s = amp;quot;%samp;quot;%n&quot;, s); System.out.printf(&quot;s. l ength () = %d%n&quot;, s.length()); for (int i = 0; i < s.length(); i++) { System.out.printf(&quot;s[%d] = %c%n&quot;, i, s.charAt(i)); }
  • 9. Strings – First Example Live Demo
  • 10. Declaring, Creating, Reading and Printing Creating and Using Strings
  • 11.
  • 12.
  • 13.
  • 14.
  • 15. Live Demo Reading and Printing Strings
  • 16. Manipulating Strings Comparing, Concatenating, Searching, Extracting Substrings, Splitting
  • 17.
  • 18.
  • 19.
  • 20.
  • 22.
  • 23. Concatenating Strings – Example String firstName = &quot;Svetlin&quot;; String lastName = &quot;Nakov&quot;; String fullName = firstName + &quot; &quot; + lastName; System.out.println(fullName); int age = 2 6 ; String nameAndAge = &quot;Name: &quot; + fullName + &quot;Age: &quot; + age; System.out.println(nameAndAge); // Name: Svetlin Nakov // Age: 2 6
  • 25.
  • 26. Searching Strings – Example String str = &quot;Java Programming Course&quot;; int index = str.indexOf(&quot;Java&quot;); // index = 0 index = str.indexOf(&quot;Course&quot;); // index = 17 index = str.indexOf(&quot;COURSE&quot;); // index = -1 // indexOf is case sensetive. -1 means not found index = str.indexOf(&quot;ram&quot;); // index = 9 index = str.indexOf(&quot;r&quot;); // index = 6 index = str.indexOf(&quot;r&quot;, 7); // index = 9 index = str.indexOf(&quot;r&quot;, 10); // index = 20 i = s.charAt(i) = 0 1 2 3 4 5 6 7 8 9 10 11 12 … J a v a P r o g r a m m …
  • 28.
  • 30.
  • 31. Splitting Strings - Example String listOfBeers = &quot;Amstel, Zagorka, Tuborg, Becks.&quot;; String[] beers = listOfBeers.split(&quot;[ ,.]&quot;); System.out.println(&quot;Available beers are:&quot;); for (String beer : beers) { if (!&quot;&quot;.equalsIgnoreCase(beer)) { System.out.println(beer); } }
  • 33. Other String Operations Replacing Substrings, Changing Character Casing, Trimming
  • 34.
  • 35.
  • 36.
  • 38. Building and Modifying Strings Using StringBuilder C lass
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46. Using StringBuilder Live Demo
  • 47. Formatting Strings Using t oString() and String. f ormat()
  • 48.
  • 49.
  • 50.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 62.

Editor's Notes

  1. * 12/04/10 07/16/96 (c) 2005 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  2. * 12/04/10 07/16/96 (c) 2005 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  3. * 12/04/10 07/16/96 (c) 2005 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  4. * 12/04/10 07/16/96 (c) 2005 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  5. * 12/04/10 07/16/96 (c) 2005 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  6. * 12/04/10 07/16/96 (c) 2005 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  7. * 12/04/10 07/16/96 (c) 2005 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  8. * 12/04/10 07/16/96 (c) 2005 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  9. * 12/04/10 07/16/96 (c) 2005 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  10. * 12/04/10 07/16/96 (c) 2005 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  11. * 12/04/10 07/16/96 (c) 2005 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  12. * 12/04/10 07/16/96 (c) 2005 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  13. * 12/04/10 07/16/96 (c) 2005 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  14. * 12/04/10 07/16/96 (c) 2005 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  15. * 12/04/10 07/16/96 (c) 2005 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  16. * 12/04/10 07/16/96 (c) 2005 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ## Introducing the StringBuffer Class StringBuffer represents strings that can be modified and extended at run time. The following example creates three new String objects, and copies all the characters each time a new String is created: String quote = &amp;quot;Fasten your seatbelts, &amp;quot;; quote = quote + &amp;quot;it’s going to be a bumpy night.&amp;quot;; It is more efficient to preallocate the amount of space required using the StringBuffer constructor, and its append() method as follows: StringBuffer quote = new StringBuffer(60); // alloc 60 chars quote.append(&amp;quot;Fasten your seatbelts, &amp;quot;); quote.append(&amp;quot; it’s going to be a bumpy night. &amp;quot;); StringBuffer also provides a number of overloaded insert() methods for inserting various types of data at a particular location in the string buffer. Instructor Note The example in the slide uses StringBuffer to reverse the characters in a string. A StringBuffer object is created, with the same length as the string. The loop traverses the String parameter in reverse order and appends each of its characters to the StringBuffer object by using append() . The StringBuffer therefore holds a reverse copy of the String parameter. At the end of the method, a new String object is created from the StringBuffer object, and this String is returned from the method .
  17. * 12/04/10 07/16/96 (c) 2005 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  18. * 12/04/10 07/16/96 (c) 2005 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  19. * 12/04/10 07/16/96 (c) 2005 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  20. * 12/04/10 07/16/96 (c) 2005 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  21. * 12/04/10 07/16/96 (c) 2005 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  22. * 12/04/10 07/16/96 (c) 2005 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  23. * 12/04/10 07/16/96 (c) 2005 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##
  24. * 12/04/10 07/16/96 (c) 2005 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.* ##