SlideShare a Scribd company logo
1 of 9
CS3135/CS2135
Object Oriented Programming (Java)
BSCS-3 / MCS-3
Lecture # 4
Arrays, String
Arrays & Loops
• Arrays in Java
• Dimensions of arrays
• Enhanced for loop
• Passing arrays to methods
• Java is strictly pass-by-value, exactly as in C.
• Array as objects
Instructor: Tanzila Kehkashan
2
String Class
• The String class represents character strings. All string literals in Java programs, such as "abc", are
implemented as instances of this class.
• String str = "abc";
is equivalent to:
• char data[] = {'a', 'b', 'c'};
String str = new String(data);
• String()
• String(String)
• char charAt(int) //index
• int codePointAt(int)// index
• int compareTo(String) //returns 0 if true
• int compareToIgnoreCase(String)
• Stringconcat(String)
Instructor: Tanzila Kehkashan
3
String Class
• boolean contains(String)
• boolean startsWith(String)
• boolean endsWith(String)
• int indexOf(char)
• int indexOf(char, int) // int is index from where to start search
• int indexOf(String)
• int indexOf(String, int)
• int lastIndexOf(char) //starting backward
• int lastIndexOf(char, int)
• int lastIndexOf(String)
• int lastIndexOf(String, int)
• int length()
Instructor: Tanzila Kehkashan
4
String Class
• boolean isEmpty()
• String replace(char, char) //replaces all occurances
• String replace(String, String)
• String replaceFirst(String, String)
• String substring(int) // starting index to end
• String substring(int beginIndex, int endIndex) // starting index, ending index
• char[] toCharArray()
• String toLowerCase()
• String toUpperCase()
• String trim()
Instructor: Tanzila Kehkashan
5
Assignment
• Write a program in Java which
• Takes a string from user
• Asks which option to perform from following:
• Cut & paste
• Copy & paste
• Replace All
• And then displays updated string.
• At the end program displays following statistics of updated string
• Character count excluding spaces
• Word count
Instructor: Tanzila Kehkashan
6
Instructor: Tanzila Kehkashan
7
Instructor: Tanzila Kehkashan
8
Instructor: Tanzila Kehkashan
9

More Related Content

Similar to OOP Lecture 4-Arrays, String.pptx

Java R20 - UNIT-5.docx
Java R20 - UNIT-5.docxJava R20 - UNIT-5.docx
Java R20 - UNIT-5.docxPamarthi Kumar
 
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
 
Strings in c mrs.sowmya jyothi
Strings in c mrs.sowmya jyothiStrings in c mrs.sowmya jyothi
Strings in c mrs.sowmya jyothiSowmya Jyothi
 
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
 
String classes and its methods.20
String classes and its methods.20String classes and its methods.20
String classes and its methods.20myrajendra
 
Learn C# Programming - Nullables & Arrays
Learn C# Programming - Nullables & ArraysLearn C# Programming - Nullables & Arrays
Learn C# Programming - Nullables & ArraysEng Teong Cheah
 
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
 
javastringexample problems using string class
javastringexample problems using string classjavastringexample problems using string class
javastringexample problems using string classfedcoordinator
 
Java Object Orientend Programming 1.pptx
Java Object Orientend Programming 1.pptxJava Object Orientend Programming 1.pptx
Java Object Orientend Programming 1.pptxOmarBinkasimSefat
 
CPSTRINGSARGAVISTRINGS.PPT
CPSTRINGSARGAVISTRINGS.PPTCPSTRINGSARGAVISTRINGS.PPT
CPSTRINGSARGAVISTRINGS.PPTSasideepa
 

Similar to OOP Lecture 4-Arrays, String.pptx (20)

Java R20 - UNIT-5.docx
Java R20 - UNIT-5.docxJava R20 - UNIT-5.docx
Java R20 - UNIT-5.docx
 
Java Strings
Java StringsJava Strings
Java Strings
 
Strings in Java
Strings in JavaStrings in Java
Strings in Java
 
String.ppt
String.pptString.ppt
String.ppt
 
8. String
8. String8. String
8. String
 
Java String Handling
Java String HandlingJava String Handling
Java String Handling
 
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
 
Strings in c mrs.sowmya jyothi
Strings in c mrs.sowmya jyothiStrings in c mrs.sowmya jyothi
Strings in c mrs.sowmya jyothi
 
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...
 
String classes and its methods.20
String classes and its methods.20String classes and its methods.20
String classes and its methods.20
 
Learn C# Programming - Nullables & Arrays
Learn C# Programming - Nullables & ArraysLearn C# Programming - Nullables & Arrays
Learn C# Programming - Nullables & Arrays
 
kotlin-nutshell.pptx
kotlin-nutshell.pptxkotlin-nutshell.pptx
kotlin-nutshell.pptx
 
Handling of character strings C programming
Handling of character strings C programmingHandling of character strings C programming
Handling of character strings C programming
 
Java string handling
Java string handlingJava string handling
Java string handling
 
String handling
String handlingString handling
String handling
 
String c
String cString c
String c
 
javastringexample problems using string class
javastringexample problems using string classjavastringexample problems using string class
javastringexample problems using string class
 
Lect10
Lect10Lect10
Lect10
 
Java Object Orientend Programming 1.pptx
Java Object Orientend Programming 1.pptxJava Object Orientend Programming 1.pptx
Java Object Orientend Programming 1.pptx
 
CPSTRINGSARGAVISTRINGS.PPT
CPSTRINGSARGAVISTRINGS.PPTCPSTRINGSARGAVISTRINGS.PPT
CPSTRINGSARGAVISTRINGS.PPT
 

More from Tanzila Kehkashan

OOP Lecture 25-Network Programming-Part2.pptx
OOP Lecture 25-Network Programming-Part2.pptxOOP Lecture 25-Network Programming-Part2.pptx
OOP Lecture 25-Network Programming-Part2.pptxTanzila Kehkashan
 
OOP Lecture 24-Network Programming-Part1.pptx
OOP Lecture 24-Network Programming-Part1.pptxOOP Lecture 24-Network Programming-Part1.pptx
OOP Lecture 24-Network Programming-Part1.pptxTanzila Kehkashan
 
OOP Lecture 23-JAR Files.pptx
OOP Lecture 23-JAR Files.pptxOOP Lecture 23-JAR Files.pptx
OOP Lecture 23-JAR Files.pptxTanzila Kehkashan
 
OOP Lecture 21-Graphics, Audio.pptx
OOP Lecture 21-Graphics, Audio.pptxOOP Lecture 21-Graphics, Audio.pptx
OOP Lecture 21-Graphics, Audio.pptxTanzila Kehkashan
 
OOP Lecture 20-MultiThreading.pptx
OOP Lecture 20-MultiThreading.pptxOOP Lecture 20-MultiThreading.pptx
OOP Lecture 20-MultiThreading.pptxTanzila Kehkashan
 
OOP Lecture 19-JMenuBar.pptx
OOP Lecture 19-JMenuBar.pptxOOP Lecture 19-JMenuBar.pptx
OOP Lecture 19-JMenuBar.pptxTanzila Kehkashan
 
OOP Lecture 18-DB Connectivity-Part2.pptx
OOP Lecture 18-DB Connectivity-Part2.pptxOOP Lecture 18-DB Connectivity-Part2.pptx
OOP Lecture 18-DB Connectivity-Part2.pptxTanzila Kehkashan
 
OOP Lecture 17-DB Connectivity-Part1.pptx
OOP Lecture 17-DB Connectivity-Part1.pptxOOP Lecture 17-DB Connectivity-Part1.pptx
OOP Lecture 17-DB Connectivity-Part1.pptxTanzila Kehkashan
 
OOP Lecture 16-Math,Timer.pptx
OOP Lecture 16-Math,Timer.pptxOOP Lecture 16-Math,Timer.pptx
OOP Lecture 16-Math,Timer.pptxTanzila Kehkashan
 
OOP Lecture 15-FileHandling,JFileChooser.pptx
OOP Lecture 15-FileHandling,JFileChooser.pptxOOP Lecture 15-FileHandling,JFileChooser.pptx
OOP Lecture 15-FileHandling,JFileChooser.pptxTanzila Kehkashan
 
OOP Lecture 14-ExceptionHandling.pptx
OOP Lecture 14-ExceptionHandling.pptxOOP Lecture 14-ExceptionHandling.pptx
OOP Lecture 14-ExceptionHandling.pptxTanzila Kehkashan
 
OOP Lecture 13-Color,Font,ImageIcon.pptx
OOP Lecture 13-Color,Font,ImageIcon.pptxOOP Lecture 13-Color,Font,ImageIcon.pptx
OOP Lecture 13-Color,Font,ImageIcon.pptxTanzila Kehkashan
 
OOP Lecture 12-EventHandling2.pptx
OOP Lecture 12-EventHandling2.pptxOOP Lecture 12-EventHandling2.pptx
OOP Lecture 12-EventHandling2.pptxTanzila Kehkashan
 
OOP Lecture 11-EventHandling1.pptx
OOP Lecture 11-EventHandling1.pptxOOP Lecture 11-EventHandling1.pptx
OOP Lecture 11-EventHandling1.pptxTanzila Kehkashan
 
OOP Lecture 10-JTable,JTabbedPane,LayoutManagers.pptx
OOP Lecture 10-JTable,JTabbedPane,LayoutManagers.pptxOOP Lecture 10-JTable,JTabbedPane,LayoutManagers.pptx
OOP Lecture 10-JTable,JTabbedPane,LayoutManagers.pptxTanzila Kehkashan
 
OOP Lecture 9-JComboBox,JList,JPanel.pptx
OOP Lecture 9-JComboBox,JList,JPanel.pptxOOP Lecture 9-JComboBox,JList,JPanel.pptx
OOP Lecture 9-JComboBox,JList,JPanel.pptxTanzila Kehkashan
 
OOP Lecture 8-JCheckBox,JRadioButton,JProgressBar.pptx
OOP Lecture 8-JCheckBox,JRadioButton,JProgressBar.pptxOOP Lecture 8-JCheckBox,JRadioButton,JProgressBar.pptx
OOP Lecture 8-JCheckBox,JRadioButton,JProgressBar.pptxTanzila Kehkashan
 
OOP Lecture 7-JTextField,JTextArea,JPassword,JButton.pptx
OOP Lecture 7-JTextField,JTextArea,JPassword,JButton.pptxOOP Lecture 7-JTextField,JTextArea,JPassword,JButton.pptx
OOP Lecture 7-JTextField,JTextArea,JPassword,JButton.pptxTanzila Kehkashan
 
OOP Lecture 6-JFrame,JScrollPane,JLabel.pptx
OOP Lecture 6-JFrame,JScrollPane,JLabel.pptxOOP Lecture 6-JFrame,JScrollPane,JLabel.pptx
OOP Lecture 6-JFrame,JScrollPane,JLabel.pptxTanzila Kehkashan
 

More from Tanzila Kehkashan (20)

OOP Lecture 25-Network Programming-Part2.pptx
OOP Lecture 25-Network Programming-Part2.pptxOOP Lecture 25-Network Programming-Part2.pptx
OOP Lecture 25-Network Programming-Part2.pptx
 
OOP Lecture 24-Network Programming-Part1.pptx
OOP Lecture 24-Network Programming-Part1.pptxOOP Lecture 24-Network Programming-Part1.pptx
OOP Lecture 24-Network Programming-Part1.pptx
 
OOP Lecture 23-JAR Files.pptx
OOP Lecture 23-JAR Files.pptxOOP Lecture 23-JAR Files.pptx
OOP Lecture 23-JAR Files.pptx
 
OOP Lecture 22-JApplet.pptx
OOP Lecture 22-JApplet.pptxOOP Lecture 22-JApplet.pptx
OOP Lecture 22-JApplet.pptx
 
OOP Lecture 21-Graphics, Audio.pptx
OOP Lecture 21-Graphics, Audio.pptxOOP Lecture 21-Graphics, Audio.pptx
OOP Lecture 21-Graphics, Audio.pptx
 
OOP Lecture 20-MultiThreading.pptx
OOP Lecture 20-MultiThreading.pptxOOP Lecture 20-MultiThreading.pptx
OOP Lecture 20-MultiThreading.pptx
 
OOP Lecture 19-JMenuBar.pptx
OOP Lecture 19-JMenuBar.pptxOOP Lecture 19-JMenuBar.pptx
OOP Lecture 19-JMenuBar.pptx
 
OOP Lecture 18-DB Connectivity-Part2.pptx
OOP Lecture 18-DB Connectivity-Part2.pptxOOP Lecture 18-DB Connectivity-Part2.pptx
OOP Lecture 18-DB Connectivity-Part2.pptx
 
OOP Lecture 17-DB Connectivity-Part1.pptx
OOP Lecture 17-DB Connectivity-Part1.pptxOOP Lecture 17-DB Connectivity-Part1.pptx
OOP Lecture 17-DB Connectivity-Part1.pptx
 
OOP Lecture 16-Math,Timer.pptx
OOP Lecture 16-Math,Timer.pptxOOP Lecture 16-Math,Timer.pptx
OOP Lecture 16-Math,Timer.pptx
 
OOP Lecture 15-FileHandling,JFileChooser.pptx
OOP Lecture 15-FileHandling,JFileChooser.pptxOOP Lecture 15-FileHandling,JFileChooser.pptx
OOP Lecture 15-FileHandling,JFileChooser.pptx
 
OOP Lecture 14-ExceptionHandling.pptx
OOP Lecture 14-ExceptionHandling.pptxOOP Lecture 14-ExceptionHandling.pptx
OOP Lecture 14-ExceptionHandling.pptx
 
OOP Lecture 13-Color,Font,ImageIcon.pptx
OOP Lecture 13-Color,Font,ImageIcon.pptxOOP Lecture 13-Color,Font,ImageIcon.pptx
OOP Lecture 13-Color,Font,ImageIcon.pptx
 
OOP Lecture 12-EventHandling2.pptx
OOP Lecture 12-EventHandling2.pptxOOP Lecture 12-EventHandling2.pptx
OOP Lecture 12-EventHandling2.pptx
 
OOP Lecture 11-EventHandling1.pptx
OOP Lecture 11-EventHandling1.pptxOOP Lecture 11-EventHandling1.pptx
OOP Lecture 11-EventHandling1.pptx
 
OOP Lecture 10-JTable,JTabbedPane,LayoutManagers.pptx
OOP Lecture 10-JTable,JTabbedPane,LayoutManagers.pptxOOP Lecture 10-JTable,JTabbedPane,LayoutManagers.pptx
OOP Lecture 10-JTable,JTabbedPane,LayoutManagers.pptx
 
OOP Lecture 9-JComboBox,JList,JPanel.pptx
OOP Lecture 9-JComboBox,JList,JPanel.pptxOOP Lecture 9-JComboBox,JList,JPanel.pptx
OOP Lecture 9-JComboBox,JList,JPanel.pptx
 
OOP Lecture 8-JCheckBox,JRadioButton,JProgressBar.pptx
OOP Lecture 8-JCheckBox,JRadioButton,JProgressBar.pptxOOP Lecture 8-JCheckBox,JRadioButton,JProgressBar.pptx
OOP Lecture 8-JCheckBox,JRadioButton,JProgressBar.pptx
 
OOP Lecture 7-JTextField,JTextArea,JPassword,JButton.pptx
OOP Lecture 7-JTextField,JTextArea,JPassword,JButton.pptxOOP Lecture 7-JTextField,JTextArea,JPassword,JButton.pptx
OOP Lecture 7-JTextField,JTextArea,JPassword,JButton.pptx
 
OOP Lecture 6-JFrame,JScrollPane,JLabel.pptx
OOP Lecture 6-JFrame,JScrollPane,JLabel.pptxOOP Lecture 6-JFrame,JScrollPane,JLabel.pptx
OOP Lecture 6-JFrame,JScrollPane,JLabel.pptx
 

Recently uploaded

How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfCionsystems
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
Clustering techniques data mining book ....
Clustering techniques data mining book ....Clustering techniques data mining book ....
Clustering techniques data mining book ....ShaimaaMohamedGalal
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 

Recently uploaded (20)

Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdf
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Clustering techniques data mining book ....
Clustering techniques data mining book ....Clustering techniques data mining book ....
Clustering techniques data mining book ....
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 

OOP Lecture 4-Arrays, String.pptx

  • 1. CS3135/CS2135 Object Oriented Programming (Java) BSCS-3 / MCS-3 Lecture # 4 Arrays, String
  • 2. Arrays & Loops • Arrays in Java • Dimensions of arrays • Enhanced for loop • Passing arrays to methods • Java is strictly pass-by-value, exactly as in C. • Array as objects Instructor: Tanzila Kehkashan 2
  • 3. String Class • The String class represents character strings. All string literals in Java programs, such as "abc", are implemented as instances of this class. • String str = "abc"; is equivalent to: • char data[] = {'a', 'b', 'c'}; String str = new String(data); • String() • String(String) • char charAt(int) //index • int codePointAt(int)// index • int compareTo(String) //returns 0 if true • int compareToIgnoreCase(String) • Stringconcat(String) Instructor: Tanzila Kehkashan 3
  • 4. String Class • boolean contains(String) • boolean startsWith(String) • boolean endsWith(String) • int indexOf(char) • int indexOf(char, int) // int is index from where to start search • int indexOf(String) • int indexOf(String, int) • int lastIndexOf(char) //starting backward • int lastIndexOf(char, int) • int lastIndexOf(String) • int lastIndexOf(String, int) • int length() Instructor: Tanzila Kehkashan 4
  • 5. String Class • boolean isEmpty() • String replace(char, char) //replaces all occurances • String replace(String, String) • String replaceFirst(String, String) • String substring(int) // starting index to end • String substring(int beginIndex, int endIndex) // starting index, ending index • char[] toCharArray() • String toLowerCase() • String toUpperCase() • String trim() Instructor: Tanzila Kehkashan 5
  • 6. Assignment • Write a program in Java which • Takes a string from user • Asks which option to perform from following: • Cut & paste • Copy & paste • Replace All • And then displays updated string. • At the end program displays following statistics of updated string • Character count excluding spaces • Word count Instructor: Tanzila Kehkashan 6