SlideShare uma empresa Scribd logo
1 de 23
TEST (MODULE:- 1 and 2)
 What are command line arguments? Write a program in JAVA to print

  Fibonacci series using command line arguments?      [10]

 Create a class employee with data members empid, empname, designation

  and salary. Write methods for:-                     [10]

  get_employee()- To take user input.

  show_grade()- To display grade of employee based on salary.

  show_employee()- To show employee details.

 Write a note on:-                                   [10]
   Java Virtual Machine.

   Nesting of Methods with example
STRINGS
   IN
 JAVA
          - Ankita Karia
STRINGS
 Strings represent a sequence of characters.
 The easiest way to represent a sequence of characters in
  JAVA is by using a character array.
 char Array[ ] = new char [5];             Character arrays are
                                              not good enough to
                                             support the range of
                                             operations we want to
                                              perform on strings.


    In JAVA strings are class objects and implemented using
    two classes:-
        String
        StringBuffer.
    In JAVA strings are not a character array and is not NULL
    terminated.
DECLARING & INITIALISING

•   Normally, objects in Java are created with the new keyword.

    String name;
     name = new String("Craig");

                                OR
     String name= new String("Craig");


•   However, String objects can be created "implicitly":
                 String name;
                 name = "Craig";
The String Class


String objects are handled specially by the compiler.
 String is the only class which has "implicit" instantiation.
The String class is defined in the java.lang package.
Strings are immutable.
 The value of a String object can never be changed.
 For mutable Strings, use the StringBuffer class.
DYNAMIC INITIALIZATION
           OF STRINGS
BufferedReader br = new BufferedReader(new
 InputStreamReader(System.in));

    String city = br.readLine();    Give throws
                                    IOException
                                       beside
                                      function
                                        name

Scanner sc=new Scanner(System.in);
    String state=sc.nextLine();
   String state1=sc.next();
STRING CONCATENATION
    JAVA string can be concatenated
     using + operator.
 String name="Ankita";
 String surname="Karia";
 System.out.println(name+" "+surname);

STRING Arrays
•An array of strings can also be created
        String cities [ ] = new String[5];
• Will create an array of CITIES of size 5 to
hold string constants
String Methods
   The String class contains many useful methods for string-
    processing applications.
    ◦ A String method is called by writing a String object, a dot, the name of
      the method, and a pair of parentheses to enclose any arguments

    ◦ If a String method returns a value, then it can be placed anywhere that a
      value of its type can be used

      String greeting = "Hello";         String method
      int count = greeting.length();
      System.out.println("Length is " + greeting.length());

    ◦ Always count from zero when referring to the position or index of a
      character in a string
String Indexes
Some Methods in the Class String (Part 1
of 8)




                        1-10
Some Methods in the Class String (Part 2
of 8)
Some Methods in the Class String (Part 3
of 8)
Some Methods in the Class String (Part 4 o
8)
Some Methods in the Class String (Part 5 o
8)
Some Methods in the Class String (Part 6
of 8)
Some Methods in the Class String (Part 7 o
STRING BUFFER

               CLASS
    STRINGBUFFER class creates strings flexible length that
    can be modified in terms of both length and content.

   STRINGBUFFER may have characters and substrings
    inserted in the middle or appended to the end.

   STRINGBUFFER automatically grows to make room for
    such additions

                      Actually STRINGBUFFER has more
                     characters pre allocated than are actually
                        needed, to allow room for growth
STRING BUFFER
              CONSTRUCTORS
   String Buffer():- Reserves room fro 16 characters
    without reallocation


   StringBuffer(int size):- Accepts an integer argunent
    that explicilty sets the size of the buffer


   StringBuffer(String str):- Accepts STRING argument
    that sets the initial contents of the STRINGBUFFER and
    allocated room for 16 additional characters.
STRING BUFFER FUNCTIONS
   length():-Returns the current length of the string.

   capacity():- Returns the total allocated capacity.

   void ensureCapacity():- Preallocates room for a certain

                    number of characters.
   void setLength(int len):- Sets the length of the string s1
                              to len.
               If len<s1.length(), s1 is truncated.
               If len>s1.length(), zeros are added to s1.
   charAt(int where):- Extracts value of a single character.

   setCharAt(int where, char ch):- Sets the value of character

                     at specified position.
STRING BUFFER FUNCTIONS
   append(s2):- Appends string s2 to s1 at the end.

   insert(n,s2 ):- Inserts the string s2 at the position n of the
    string s1

   reverse():- Returns the reversed object on when it is called.

   delete(int n1,int n2):- Deletes a sequence of characters
    from the invoking object.

                 n1      Specifies index of first character to remove

                          Specifies index one past the lastcharacter to
                  n2      remove

   deleteCharAt(int loc):- Deletes the character at the index
    specified by loc.
STRING BUFFER FUNCTIONS
   replace(int n1,int n2,String s1):- Replaces one set of
    characters with another set.

   substring(int startIndex):- Returns the substring that starts
    at starts at startIndex and runs to the end.

   substring(int startIndex, int endIndex):- Returns the
    substring that starts at starts at startIndex and runs to the
    endIndex-1




VECTOR

Mais conteúdo relacionado

Mais procurados

Java Exception handling
Java Exception handlingJava Exception handling
Java Exception handlingkamal kotecha
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in javaTech_MX
 
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
 
String and string buffer
String and string bufferString and string buffer
String and string bufferkamal kotecha
 
Presentation on-exception-handling
Presentation on-exception-handlingPresentation on-exception-handling
Presentation on-exception-handlingNahian Ahmed
 
Control Statements in Java
Control Statements in JavaControl Statements in Java
Control Statements in JavaNiloy Saha
 
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
 
oops concept in java | object oriented programming in java
oops concept in java | object oriented programming in javaoops concept in java | object oriented programming in java
oops concept in java | object oriented programming in javaCPD INDIA
 
This keyword in java
This keyword in javaThis keyword in java
This keyword in javaHitesh Kumar
 
String classes and its methods.20
String classes and its methods.20String classes and its methods.20
String classes and its methods.20myrajendra
 

Mais procurados (20)

Java Exception handling
Java Exception handlingJava Exception handling
Java Exception handling
 
Java Arrays
Java ArraysJava Arrays
Java Arrays
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
 
String Builder & String Buffer (Java Programming)
String Builder & String Buffer (Java Programming)String Builder & String Buffer (Java Programming)
String Builder & String Buffer (Java Programming)
 
String and string buffer
String and string bufferString and string buffer
String and string buffer
 
String, string builder, string buffer
String, string builder, string bufferString, string builder, string buffer
String, string builder, string buffer
 
Java String
Java StringJava String
Java String
 
Presentation on-exception-handling
Presentation on-exception-handlingPresentation on-exception-handling
Presentation on-exception-handling
 
Control Statements in Java
Control Statements in JavaControl Statements in Java
Control Statements in Java
 
JAVA AWT
JAVA AWTJAVA AWT
JAVA AWT
 
Java constructors
Java constructorsJava constructors
Java constructors
 
Java threads
Java threadsJava threads
Java threads
 
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
 
Arrays in java
Arrays in javaArrays in java
Arrays in java
 
Java input
Java inputJava input
Java input
 
Java program structure
Java program structureJava program structure
Java program structure
 
oops concept in java | object oriented programming in java
oops concept in java | object oriented programming in javaoops concept in java | object oriented programming in java
oops concept in java | object oriented programming in java
 
This keyword in java
This keyword in javaThis keyword in java
This keyword in java
 
String classes and its methods.20
String classes and its methods.20String classes and its methods.20
String classes and its methods.20
 
Vectors in Java
Vectors in JavaVectors in Java
Vectors in Java
 

Destaque

String handling(string class)
String handling(string class)String handling(string class)
String handling(string class)Ravi_Kant_Sahu
 
String java
String javaString java
String java774474
 
String Handling in c++
String Handling in c++String Handling in c++
String Handling in c++Fahim Adil
 
Java multi threading
Java multi threadingJava multi threading
Java multi threadingRaja Sekhar
 
Chapter 3:Programming with Java Operators and Strings
Chapter 3:Programming with Java Operators and  StringsChapter 3:Programming with Java Operators and  Strings
Chapter 3:Programming with Java Operators and StringsIt Academy
 
Strings and common operations
Strings and common operationsStrings and common operations
Strings and common operationsTurnToTech
 
Java: strings e arrays
Java: strings e arraysJava: strings e arrays
Java: strings e arraysArthur Emanuel
 
Final keyword in java
Final keyword in javaFinal keyword in java
Final keyword in javaHitesh Kumar
 
Save Time, Money and Bloodshed with Soft System Discovery
Save Time, Money and Bloodshed with Soft System DiscoverySave Time, Money and Bloodshed with Soft System Discovery
Save Time, Money and Bloodshed with Soft System DiscoveryBrightEdge
 
L21 io streams
L21 io streamsL21 io streams
L21 io streamsteach4uin
 
Ppt on this and super keyword
Ppt on this and super keywordPpt on this and super keyword
Ppt on this and super keywordtanu_jaswal
 
L13 string handling(string class)
L13 string handling(string class)L13 string handling(string class)
L13 string handling(string class)teach4uin
 

Destaque (20)

Java String
Java String Java String
Java String
 
String Handling
String HandlingString Handling
String Handling
 
Java strings
Java   stringsJava   strings
Java strings
 
String handling(string class)
String handling(string class)String handling(string class)
String handling(string class)
 
Strings
StringsStrings
Strings
 
Java tutorial PPT
Java tutorial PPTJava tutorial PPT
Java tutorial PPT
 
String java
String javaString java
String java
 
String Handling in c++
String Handling in c++String Handling in c++
String Handling in c++
 
Java multi threading
Java multi threadingJava multi threading
Java multi threading
 
Chapter 3:Programming with Java Operators and Strings
Chapter 3:Programming with Java Operators and  StringsChapter 3:Programming with Java Operators and  Strings
Chapter 3:Programming with Java Operators and Strings
 
StringTokenizer in java
StringTokenizer in javaStringTokenizer in java
StringTokenizer in java
 
Strings and common operations
Strings and common operationsStrings and common operations
Strings and common operations
 
Java: strings e arrays
Java: strings e arraysJava: strings e arrays
Java: strings e arrays
 
Final keyword in java
Final keyword in javaFinal keyword in java
Final keyword in java
 
Save Time, Money and Bloodshed with Soft System Discovery
Save Time, Money and Bloodshed with Soft System DiscoverySave Time, Money and Bloodshed with Soft System Discovery
Save Time, Money and Bloodshed with Soft System Discovery
 
L21 io streams
L21 io streamsL21 io streams
L21 io streams
 
Ppt on this and super keyword
Ppt on this and super keywordPpt on this and super keyword
Ppt on this and super keyword
 
L13 string handling(string class)
L13 string handling(string class)L13 string handling(string class)
L13 string handling(string class)
 
String operation
String operationString operation
String operation
 
Java 06 Strings Arrays
Java 06 Strings ArraysJava 06 Strings Arrays
Java 06 Strings Arrays
 

Semelhante a Strings in Java

javastringexample problems using string class
javastringexample problems using string classjavastringexample problems using string class
javastringexample problems using string classfedcoordinator
 
String Handling, Inheritance, Packages and Interfaces
String Handling, Inheritance, Packages and InterfacesString Handling, Inheritance, Packages and Interfaces
String Handling, Inheritance, Packages and InterfacesPrabu U
 
Module-1 Strings Handling.ppt.pdf
Module-1 Strings Handling.ppt.pdfModule-1 Strings Handling.ppt.pdf
Module-1 Strings Handling.ppt.pdflearnEnglish51
 
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
 
Strings Arrays
Strings ArraysStrings Arrays
Strings Arraysphanleson
 
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
 
Java R20 - UNIT-5.docx
Java R20 - UNIT-5.docxJava R20 - UNIT-5.docx
Java R20 - UNIT-5.docxPamarthi Kumar
 
Strings in c
Strings in cStrings in c
Strings in cvampugani
 
3.7_StringBuilder.pdf
3.7_StringBuilder.pdf3.7_StringBuilder.pdf
3.7_StringBuilder.pdfAnanthi68
 

Semelhante a Strings in Java (20)

javastringexample problems using string class
javastringexample problems using string classjavastringexample problems using string class
javastringexample problems using string class
 
String Handling, Inheritance, Packages and Interfaces
String Handling, Inheritance, Packages and InterfacesString Handling, Inheritance, Packages and Interfaces
String Handling, Inheritance, Packages and Interfaces
 
07slide
07slide07slide
07slide
 
Module-1 Strings Handling.ppt.pdf
Module-1 Strings Handling.ppt.pdfModule-1 Strings Handling.ppt.pdf
Module-1 Strings Handling.ppt.pdf
 
Day_5.1.pptx
Day_5.1.pptxDay_5.1.pptx
Day_5.1.pptx
 
StringBuffer.pptx
StringBuffer.pptxStringBuffer.pptx
StringBuffer.pptx
 
Java String Handling
Java String HandlingJava String Handling
Java String Handling
 
package
packagepackage
package
 
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
 
Strings Arrays
Strings ArraysStrings Arrays
Strings Arrays
 
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...
 
Java
JavaJava
Java
 
Chapter 7 String
Chapter 7 StringChapter 7 String
Chapter 7 String
 
Java R20 - UNIT-5.pdf
Java R20 - UNIT-5.pdfJava R20 - UNIT-5.pdf
Java R20 - UNIT-5.pdf
 
Java R20 - UNIT-5.docx
Java R20 - UNIT-5.docxJava R20 - UNIT-5.docx
Java R20 - UNIT-5.docx
 
Strings in c++
Strings in c++Strings in c++
Strings in c++
 
Strings in c
Strings in cStrings in c
Strings in c
 
3.7_StringBuilder.pdf
3.7_StringBuilder.pdf3.7_StringBuilder.pdf
3.7_StringBuilder.pdf
 
M C6java7
M C6java7M C6java7
M C6java7
 

Mais de Abhilash Nair

Sequential Circuits - Flip Flops
Sequential Circuits - Flip FlopsSequential Circuits - Flip Flops
Sequential Circuits - Flip FlopsAbhilash Nair
 
Designing Clocked Synchronous State Machine
Designing Clocked Synchronous State MachineDesigning Clocked Synchronous State Machine
Designing Clocked Synchronous State MachineAbhilash Nair
 
VHDL - Enumerated Types (Part 3)
VHDL - Enumerated Types (Part 3)VHDL - Enumerated Types (Part 3)
VHDL - Enumerated Types (Part 3)Abhilash Nair
 
Introduction to VHDL - Part 1
Introduction to VHDL - Part 1Introduction to VHDL - Part 1
Introduction to VHDL - Part 1Abhilash Nair
 
Feedback Sequential Circuits
Feedback Sequential CircuitsFeedback Sequential Circuits
Feedback Sequential CircuitsAbhilash Nair
 
Designing State Machine
Designing State MachineDesigning State Machine
Designing State MachineAbhilash Nair
 
State Machine Design and Synthesis
State Machine Design and SynthesisState Machine Design and Synthesis
State Machine Design and SynthesisAbhilash Nair
 
Synchronous design process
Synchronous design processSynchronous design process
Synchronous design processAbhilash Nair
 
Analysis of state machines & Conversion of models
Analysis of state machines & Conversion of modelsAnalysis of state machines & Conversion of models
Analysis of state machines & Conversion of modelsAbhilash Nair
 
Analysis of state machines
Analysis of state machinesAnalysis of state machines
Analysis of state machinesAbhilash Nair
 
Sequential Circuits - Flip Flops (Part 2)
Sequential Circuits - Flip Flops (Part 2)Sequential Circuits - Flip Flops (Part 2)
Sequential Circuits - Flip Flops (Part 2)Abhilash Nair
 
Sequential Circuits - Flip Flops (Part 1)
Sequential Circuits - Flip Flops (Part 1)Sequential Circuits - Flip Flops (Part 1)
Sequential Circuits - Flip Flops (Part 1)Abhilash Nair
 

Mais de Abhilash Nair (20)

Sequential Circuits - Flip Flops
Sequential Circuits - Flip FlopsSequential Circuits - Flip Flops
Sequential Circuits - Flip Flops
 
VHDL Part 4
VHDL Part 4VHDL Part 4
VHDL Part 4
 
Designing Clocked Synchronous State Machine
Designing Clocked Synchronous State MachineDesigning Clocked Synchronous State Machine
Designing Clocked Synchronous State Machine
 
MSI Shift Registers
MSI Shift RegistersMSI Shift Registers
MSI Shift Registers
 
VHDL - Enumerated Types (Part 3)
VHDL - Enumerated Types (Part 3)VHDL - Enumerated Types (Part 3)
VHDL - Enumerated Types (Part 3)
 
VHDL - Part 2
VHDL - Part 2VHDL - Part 2
VHDL - Part 2
 
Introduction to VHDL - Part 1
Introduction to VHDL - Part 1Introduction to VHDL - Part 1
Introduction to VHDL - Part 1
 
Feedback Sequential Circuits
Feedback Sequential CircuitsFeedback Sequential Circuits
Feedback Sequential Circuits
 
Designing State Machine
Designing State MachineDesigning State Machine
Designing State Machine
 
State Machine Design and Synthesis
State Machine Design and SynthesisState Machine Design and Synthesis
State Machine Design and Synthesis
 
Synchronous design process
Synchronous design processSynchronous design process
Synchronous design process
 
Analysis of state machines & Conversion of models
Analysis of state machines & Conversion of modelsAnalysis of state machines & Conversion of models
Analysis of state machines & Conversion of models
 
Analysis of state machines
Analysis of state machinesAnalysis of state machines
Analysis of state machines
 
Sequential Circuits - Flip Flops (Part 2)
Sequential Circuits - Flip Flops (Part 2)Sequential Circuits - Flip Flops (Part 2)
Sequential Circuits - Flip Flops (Part 2)
 
Sequential Circuits - Flip Flops (Part 1)
Sequential Circuits - Flip Flops (Part 1)Sequential Circuits - Flip Flops (Part 1)
Sequential Circuits - Flip Flops (Part 1)
 
FPGA
FPGAFPGA
FPGA
 
FPLDs
FPLDsFPLDs
FPLDs
 
CPLDs
CPLDsCPLDs
CPLDs
 
CPLD & FPLD
CPLD & FPLDCPLD & FPLD
CPLD & FPLD
 
CPLDs
CPLDsCPLDs
CPLDs
 

Último

Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 

Último (20)

Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 

Strings in Java

  • 1. TEST (MODULE:- 1 and 2)  What are command line arguments? Write a program in JAVA to print Fibonacci series using command line arguments? [10]  Create a class employee with data members empid, empname, designation and salary. Write methods for:- [10] get_employee()- To take user input. show_grade()- To display grade of employee based on salary. show_employee()- To show employee details.  Write a note on:- [10]  Java Virtual Machine.  Nesting of Methods with example
  • 2. STRINGS IN JAVA - Ankita Karia
  • 3. STRINGS  Strings represent a sequence of characters.  The easiest way to represent a sequence of characters in JAVA is by using a character array. char Array[ ] = new char [5]; Character arrays are not good enough to support the range of operations we want to perform on strings. In JAVA strings are class objects and implemented using two classes:- String StringBuffer. In JAVA strings are not a character array and is not NULL terminated.
  • 4. DECLARING & INITIALISING • Normally, objects in Java are created with the new keyword. String name; name = new String("Craig"); OR String name= new String("Craig"); • However, String objects can be created "implicitly": String name; name = "Craig";
  • 5. The String Class String objects are handled specially by the compiler. String is the only class which has "implicit" instantiation. The String class is defined in the java.lang package. Strings are immutable.  The value of a String object can never be changed. For mutable Strings, use the StringBuffer class.
  • 6. DYNAMIC INITIALIZATION OF STRINGS BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String city = br.readLine(); Give throws IOException beside function name Scanner sc=new Scanner(System.in); String state=sc.nextLine(); String state1=sc.next();
  • 7. STRING CONCATENATION  JAVA string can be concatenated using + operator. String name="Ankita"; String surname="Karia"; System.out.println(name+" "+surname); STRING Arrays •An array of strings can also be created String cities [ ] = new String[5]; • Will create an array of CITIES of size 5 to hold string constants
  • 8. String Methods  The String class contains many useful methods for string- processing applications. ◦ A String method is called by writing a String object, a dot, the name of the method, and a pair of parentheses to enclose any arguments ◦ If a String method returns a value, then it can be placed anywhere that a value of its type can be used String greeting = "Hello"; String method int count = greeting.length(); System.out.println("Length is " + greeting.length()); ◦ Always count from zero when referring to the position or index of a character in a string
  • 10. Some Methods in the Class String (Part 1 of 8) 1-10
  • 11. Some Methods in the Class String (Part 2 of 8)
  • 12. Some Methods in the Class String (Part 3 of 8)
  • 13. Some Methods in the Class String (Part 4 o 8)
  • 14. Some Methods in the Class String (Part 5 o 8)
  • 15. Some Methods in the Class String (Part 6 of 8)
  • 16. Some Methods in the Class String (Part 7 o
  • 17.
  • 18. STRING BUFFER  CLASS STRINGBUFFER class creates strings flexible length that can be modified in terms of both length and content.  STRINGBUFFER may have characters and substrings inserted in the middle or appended to the end.  STRINGBUFFER automatically grows to make room for such additions Actually STRINGBUFFER has more characters pre allocated than are actually needed, to allow room for growth
  • 19. STRING BUFFER CONSTRUCTORS  String Buffer():- Reserves room fro 16 characters without reallocation  StringBuffer(int size):- Accepts an integer argunent that explicilty sets the size of the buffer  StringBuffer(String str):- Accepts STRING argument that sets the initial contents of the STRINGBUFFER and allocated room for 16 additional characters.
  • 20. STRING BUFFER FUNCTIONS  length():-Returns the current length of the string.  capacity():- Returns the total allocated capacity.  void ensureCapacity():- Preallocates room for a certain number of characters.  void setLength(int len):- Sets the length of the string s1 to len. If len<s1.length(), s1 is truncated. If len>s1.length(), zeros are added to s1.  charAt(int where):- Extracts value of a single character.  setCharAt(int where, char ch):- Sets the value of character at specified position.
  • 21.
  • 22. STRING BUFFER FUNCTIONS  append(s2):- Appends string s2 to s1 at the end.  insert(n,s2 ):- Inserts the string s2 at the position n of the string s1  reverse():- Returns the reversed object on when it is called.  delete(int n1,int n2):- Deletes a sequence of characters from the invoking object. n1 Specifies index of first character to remove Specifies index one past the lastcharacter to n2 remove  deleteCharAt(int loc):- Deletes the character at the index specified by loc.
  • 23. STRING BUFFER FUNCTIONS  replace(int n1,int n2,String s1):- Replaces one set of characters with another set.  substring(int startIndex):- Returns the substring that starts at starts at startIndex and runs to the end.  substring(int startIndex, int endIndex):- Returns the substring that starts at starts at startIndex and runs to the endIndex-1 VECTOR