1 / 17

Java Strings Tutorial | String Manipulation in Java | Java Tutorial For Beginners | Edureka

**** Java Certification Training: https://www.edureka.co/java-j2ee-soa-training ****<br>This Edureka tutorial on u201cJava Stringsu201d will talk about one of the most important classes of Java i.e String class. It will also talk about the various methods and interfaces implemented by the String class. Through this tutorial you will learn the following topics:<br>Java Strings<br>String Pool<br>Creating a String<br>String Methods<br><br>Check out our Java Tutorial blog series: https://goo.gl/osrGrS<br><br>Check out our complete Youtube playlist here: https://goo.gl/gMFLx3<br><br>Follow us to never miss an update in the future.<br>YouTube: https://www.youtube.com/user/edurekaIN<br>Instagram: https://www.instagram.com/edureka_learning/<br>Facebook: https://www.facebook.com/edurekaIN/<br>Twitter: https://twitter.com/edurekain<br>LinkedIn: https://www.linkedin.com/company/edureka

EdurekaIN
Télécharger la présentation

Java Strings Tutorial | String Manipulation in Java | Java Tutorial For Beginners | Edureka

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Hands On Java String Creating a String String Pool String Methods

  2. Java String Object 01 String is a Java object Characters 02 Represents a sequence of characters Class 03 java.lang.String class is used to create and manipulate strings Immutable 04 A string is immutable in nature JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training

  3. Java Strings With Strings in Java you can perform various operations, some of which are: Search The quick brown fox jumps over the lazy dog Create Substring The quick brown fox jumps over the lazy dog The quick brown fox jumps over the lazy dog The quick fox jumps The quick brown fox jumps over the lazy dog Create new strings The quick lazy dog JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training

  4. Java Strings java.lang.String JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training

  5. Java Strings Serializable Comparable CharSequence java.lang.String public final class String extends Object implements Serializable, Comparable<String>, CharSequence JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training

  6. Java Strings Serializable is a marker interface that contains no data member or method. It is used to “mark” the java classes so that objects of these classes may get a specific capability Serializable Comparable interface is used for ordering the objects of any user-defined class. This interface is found in java.lang.package and contains only one method named compareTo(Object) Comparable A CharSequence interface is a readable sequence of characters. This interface provides uniform, read-only access to various kind of character sequences CharSequence JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training

  7. Java Strings CharSequence String StringBuffer StringBuilder java.lang.StringBuilder is identical to StringBuffer except for one important difference that it is not synchronized, which means it is not thread safe java.lang.String class is used to create string objects and provides a list of methods to create and manipulate Strings java,lang.StringBuffer is a peer class of String that represents growable and writable character sequences JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training

  8. String Pool

  9. String Pool Heap Memory Java String pool refers to collection of Strings which are stored in heap memory String Pool As String objects are immutable in nature the concept of String Pool came into the picture String Pool helps in saving space for Java Runtime JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training

  10. Keyword Literal new Creating a String

  11. Creating a String – Using Literal Java String literal is created by using double quotes String str = “Edureka”; Keyword Before creating a String literal first looks for String with same value in the String pool, if found it returns the reference else it creates a new String in the pool & returns the reference Literal new Heap Memory str String Pool Edureka String str1 = “Edureka”; str1 Welcome str2 String str2 = “Welcome”; JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training

  12. Creating a String – Using new Keyword String object created using “new” keyword it always create a new object in heap memory String str = new String (“Edureka”); Keyword Literal new Heap Memory str String Pool str1 Edureka str2 Welcome str3 Edureka JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training

  13. String Methods

  14. String Methods Checks the equality of string with the given object boolean equals(Object another) Compares another string without matching the case equalsIgnoreCase() Returns a strings length length() Returns a character at a index ‘i’ charAt(i) Returns the string in uppercase toUpperCase() Returns the string in lowercase toLowerCase() Replaces all occurrences of the specified char value with the given value replace(oldVal, newVal) Removes the white spaces from the beginning and ending of string trim() Checks for the matching sequence of char value and returns true/false contains("value") Converts a string to a new character array toCharArray() Checks whether the string is empty or not IsEmpty() Checks if the string ends with the specified suffix endsWith() Concatenates two strings concat() JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training

More Related