

{"id":123465,"date":"2024-11-25T18:00:49","date_gmt":"2024-11-25T12:30:49","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=123465"},"modified":"2024-11-25T18:39:07","modified_gmt":"2024-11-25T13:09:07","slug":"java-string-methods-with-examples","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/java-string-methods-with-examples\/","title":{"rendered":"Java String Methods with Examples"},"content":{"rendered":"<p>Strings are fundamental to most programming languages, and Java is no exception. The Java String class provides robust methods and properties for working with strings in Java code.<\/p>\n<p>In this article, we will explore the ins and outs of Java strings to understand how to work with and manipulate strings efficiently in Java.<\/p>\n<p>A Java string is an object that represents a sequence of characters. The String class in Java belongs to the java.lang package, so we don&#8217;t need to import it explicitly. We will examine how to create strings, what everyday operations are available, and best practices for handling strings. Mastering the Java String class is vital to writing optimized Java code for text manipulation or processing.<\/p>\n<h2>Creating Strings in Java<\/h2>\n<p><strong>There are a few different ways to create a new Java string:<\/strong><\/p>\n<h3>The Java String Class Constructor<\/h3>\n<p><strong>We can create a string by calling the String constructor and passing a char array:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">char[] myChars = {'H', 'e', 'l', 'l', 'o'};\r\nString myString = new String(myChars);\r\nSystem.out.println(myString); \/\/ Prints \"Hello\"<\/pre>\n<h3>String Literals<\/h3>\n<p><strong>We can also use string literals enclosed in double quotes:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">String greeting = \"Hello World!\";<\/pre>\n<h4>Converting Other Data Types to Strings<\/h4>\n<p><strong>The String class provides methods for converting other data types like integers, floats, etc. to strings:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">int age = 30;\r\nString ageString = String.valueOf(age); \r\n\r\nfloat pi = 3.14f;\r\nString piString = String.valueOf(pi);<\/pre>\n<h3>Common String Operations<\/h3>\n<table>\n<tbody>\n<tr>\n<td><b>Name<\/b><\/td>\n<td><b>Description<\/b><\/td>\n<td><b>Return Value<\/b><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">charAt()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Returns the character at the specified index<\/span><\/td>\n<td><span style=\"font-weight: 400\">char<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">codePointAt()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Returns the unicode code point at the given index<\/span><\/td>\n<td><span style=\"font-weight: 400\">int<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">codePointBefore()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Returns the unicode code point before the given index<\/span><\/td>\n<td><span style=\"font-weight: 400\">int<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">codePointCount()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Returns the number of unicode code points<\/span><\/td>\n<td><span style=\"font-weight: 400\">int<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">compareTo()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Compares two strings lexicographically<\/span><\/td>\n<td><span style=\"font-weight: 400\">int<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">compareToIgnoreCase()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Compares two strings lexicographically, ignoring case<\/span><\/td>\n<td><span style=\"font-weight: 400\">int<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">concat()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Appends a string to the end of this string<\/span><\/td>\n<td><span style=\"font-weight: 400\">String<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">contains()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Checks if the string contains the given sequence<\/span><\/td>\n<td><span style=\"font-weight: 400\">boolean<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">contentEquals()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Checks string equality based on content<\/span><\/td>\n<td><span style=\"font-weight: 400\">boolean<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">copyValueOf()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Returns a String created from the chars in char array<\/span><\/td>\n<td><span style=\"font-weight: 400\">String<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">endsWith()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Checks if the string ends with given suffix<\/span><\/td>\n<td><span style=\"font-weight: 400\">boolean<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">equals()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Compares string equality<\/span><\/td>\n<td><span style=\"font-weight: 400\">boolean<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">equalsIgnoreCase()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Compares string equality ignoring case<\/span><\/td>\n<td><span style=\"font-weight: 400\">boolean<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">format()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Returns formatted string using given format and args<\/span><\/td>\n<td><span style=\"font-weight: 400\">String<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">getBytes()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Converts string to byte array<\/span><\/td>\n<td><span style=\"font-weight: 400\">byte[]<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">getChars()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Copies characters from string into char array<\/span><\/td>\n<td><span style=\"font-weight: 400\">void<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">hashCode()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Returns the hash code of the string<\/span><\/td>\n<td><span style=\"font-weight: 400\">int<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">indexOf()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Returns index of first occurrence of character\/string<\/span><\/td>\n<td><span style=\"font-weight: 400\">int<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">intern()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Returns an interned string<\/span><\/td>\n<td><span style=\"font-weight: 400\">String<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">isEmpty()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Checks if string is empty<\/span><\/td>\n<td><span style=\"font-weight: 400\">boolean<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">lastIndexOf()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Returns last index of character\/string<\/span><\/td>\n<td><span style=\"font-weight: 400\">int<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">length()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Returns the length of the string<\/span><\/td>\n<td><span style=\"font-weight: 400\">int<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">matches()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Checks if string matches given regex<\/span><\/td>\n<td><span style=\"font-weight: 400\">boolean<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">offsetByCodePoints()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Returns offset index based on unicode code points<\/span><\/td>\n<td><span style=\"font-weight: 400\">int<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">regionMatches()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Checks if region matches given string<\/span><\/td>\n<td><span style=\"font-weight: 400\">boolean<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">replace()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Replaces matches with given replacement<\/span><\/td>\n<td><span style=\"font-weight: 400\">String<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">replaceFirst()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Replaces first match with replacement<\/span><\/td>\n<td><span style=\"font-weight: 400\">String<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">replaceAll()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Replaces all matches with replacement<\/span><\/td>\n<td><span style=\"font-weight: 400\">String<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">split()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Splits string around given regex<\/span><\/td>\n<td><span style=\"font-weight: 400\">String[]<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">startsWith()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Checks if string starts with given prefix<\/span><\/td>\n<td><span style=\"font-weight: 400\">boolean<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">subSequence()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Returns a sequence of chars from string<\/span><\/td>\n<td><span style=\"font-weight: 400\">CharSequence<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">substring()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Returns a substring given begin\/end indexes<\/span><\/td>\n<td><span style=\"font-weight: 400\">String<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">toCharArray()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Converts string to a character array<\/span><\/td>\n<td><span style=\"font-weight: 400\">char[]<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">toLowerCase()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Returns lower case version of string<\/span><\/td>\n<td><span style=\"font-weight: 400\">String<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">toString()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Returns the string itself<\/span><\/td>\n<td><span style=\"font-weight: 400\">String<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">toUpperCase()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Returns upper case version of string<\/span><\/td>\n<td><span style=\"font-weight: 400\">String<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">trim()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Removes leading and trailing whitespace<\/span><\/td>\n<td><span style=\"font-weight: 400\">String<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">valueOf()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Returns a String representation of object<\/span><\/td>\n<td><span style=\"font-weight: 400\">String<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>Example<\/h4>\n<p>This Java code showcases examples of some of the most commonly used String methods in Java, including charAt(), length(), indexOf(), substring(), and equals(), demonstrating their practical usage with a sample string.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">public class StringMethodsExample {\r\n    public static void main(String[] args) {\r\n        \/\/ Define a sample string\r\n        String text = \"Hello, World!\";\r\n\r\n        \/\/ 1. charAt() - Accessing a character at a specific index\r\n        char character = text.charAt(7);\r\n        System.out.println(\"Character at index 7: \" + character);\r\n\r\n        \/\/ 2. length() - Getting the length of the string\r\n        int length = text.length();\r\n        System.out.println(\"Length of the string: \" + length);\r\n\r\n        \/\/ 3. indexOf() - Finding the position of a character or substring\r\n        int indexOfComma = text.indexOf(\",\");\r\n        System.out.println(\"Index of ',' in the string: \" + indexOfComma);\r\n\r\n        \/\/ 4. substring() - Extracting a substring from the original string\r\n        String subString = text.substring(0, 5); \/\/ Extract \"Hello\"\r\n        System.out.println(\"Substring: \" + subString);\r\n\r\n        \/\/ 5. equals() - Comparing two strings for equality\r\n        String anotherText = \"Hello, World!\";\r\n        boolean areEqual = text.equals(anotherText);\r\n        System.out.println(\"Are the two strings equal? \" + areEqual);\r\n    }\r\n}<\/pre>\n<p><strong>Output:<\/strong><br \/>\n<strong>Character at index 7:<\/strong> W<br \/>\n<strong>Length of the string:<\/strong> 13<br \/>\n<strong>Index of &#8216;,&#8217; in the string:<\/strong> 5<br \/>\n<strong>Substring:<\/strong> Hello<br \/>\nAre the two strings equal? true<\/p>\n<h3>String Handling Best Practices<\/h3>\n<p><strong>When working with Java strings, following best practices can help optimize your code:<\/strong><\/p>\n<p><strong>Immutability of String Objects:<\/strong> String objects are immutable in Java\u2014the value of a string cannot be changed once created, making them thread-safe. Any operation that modifies a string returns a new string object. Keep this in mind to avoid unintended reference changes.<\/p>\n<p><strong>Avoid Excessive String Concatenation:<\/strong> Using the + operator to concatenate strings excessively can create multiple string objects. Consider using a StringBuilder instead when programmatically generating long strings.<\/p>\n<p><strong>Use StringBuilder for Efficient String Manipulation:<\/strong> Methods like substring() and concat() return new string instances. For repeated string manipulations, StringBuilder is preferred over manual concatenation.<\/p>\n<h3>Conclusion<\/h3>\n<p>The Java String class provides rich methods and properties for working with strings. Its capabilities make creating, comparing, searching, extracting, replacing, and converting strings easy. Best practices, such as avoiding unnecessary String object creations, ensure optimal use of memory and CPU.<\/p>\n<p>This article covered the basics of Java strings &#8211; different ways to create strings, joint string operations, and string handling best practices. The String class is fundamental to Java programming, and mastering it will help you write more efficient code that works with text.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Strings are fundamental to most programming languages, and Java is no exception. The Java String class provides robust methods and properties for working with strings in Java code. In this article, we will explore&#46;&#46;&#46;<\/p>\n","protected":false},"author":86671,"featured_media":134207,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[32],"tags":[7345,31129,7699,33200,31078,8152,31131,31130,29877],"class_list":["post-123465","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java","tag-java","tag-java-string-class-methods","tag-java-string-methods","tag-java-string-methods-with-examples","tag-java-tutorials","tag-learn-java","tag-string-class-methods","tag-string-class-methods-in-java","tag-string-methods-in-java"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Java String Methods with Examples - DataFlair<\/title>\n<meta name=\"description\" content=\"A Java string is an object that represents a sequence of characters. The String class in Java belongs to the java.lang package, so we don&#039;t need to import it explicitly.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/data-flair.training\/blogs\/java-string-methods-with-examples\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Java String Methods with Examples - DataFlair\" \/>\n<meta property=\"og:description\" content=\"A Java string is an object that represents a sequence of characters. The String class in Java belongs to the java.lang package, so we don&#039;t need to import it explicitly.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/java-string-methods-with-examples\/\" \/>\n<meta property=\"og:site_name\" content=\"DataFlair\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DataFlairWS\/\" \/>\n<meta property=\"article:published_time\" content=\"2024-11-25T12:30:49+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-25T13:09:07+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/11\/java-string-class-method.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"TechVidvan Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:site\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"TechVidvan Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Java String Methods with Examples - DataFlair","description":"A Java string is an object that represents a sequence of characters. The String class in Java belongs to the java.lang package, so we don't need to import it explicitly.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/data-flair.training\/blogs\/java-string-methods-with-examples\/","og_locale":"en_US","og_type":"article","og_title":"Java String Methods with Examples - DataFlair","og_description":"A Java string is an object that represents a sequence of characters. The String class in Java belongs to the java.lang package, so we don't need to import it explicitly.","og_url":"https:\/\/data-flair.training\/blogs\/java-string-methods-with-examples\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2024-11-25T12:30:49+00:00","article_modified_time":"2024-11-25T13:09:07+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/11\/java-string-class-method.webp","type":"image\/webp"}],"author":"TechVidvan Team","twitter_card":"summary_large_image","twitter_creator":"@DataFlairWS","twitter_site":"@DataFlairWS","twitter_misc":{"Written by":"TechVidvan Team","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/java-string-methods-with-examples\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/java-string-methods-with-examples\/"},"author":{"name":"TechVidvan Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/0e594f928e31fc96628ac40f6ae74f49"},"headline":"Java String Methods with Examples","datePublished":"2024-11-25T12:30:49+00:00","dateModified":"2024-11-25T13:09:07+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/java-string-methods-with-examples\/"},"wordCount":770,"commentCount":0,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/java-string-methods-with-examples\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/11\/java-string-class-method.webp","keywords":["Java","java string class methods","Java String methods","java string methods with examples","java tutorials","Learn Java","string class methods","string class methods in java","string methods in java"],"articleSection":["Java Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/java-string-methods-with-examples\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/java-string-methods-with-examples\/","url":"https:\/\/data-flair.training\/blogs\/java-string-methods-with-examples\/","name":"Java String Methods with Examples - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/java-string-methods-with-examples\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/java-string-methods-with-examples\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/11\/java-string-class-method.webp","datePublished":"2024-11-25T12:30:49+00:00","dateModified":"2024-11-25T13:09:07+00:00","description":"A Java string is an object that represents a sequence of characters. The String class in Java belongs to the java.lang package, so we don't need to import it explicitly.","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/java-string-methods-with-examples\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/java-string-methods-with-examples\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/java-string-methods-with-examples\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/11\/java-string-class-method.webp","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2023\/11\/java-string-class-method.webp","width":1200,"height":628,"caption":"java string class method"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/java-string-methods-with-examples\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Home","item":"https:\/\/data-flair.training\/blogs\/"},{"@type":"ListItem","position":2,"name":"Java Tutorials","item":"https:\/\/data-flair.training\/blogs\/category\/java\/"},{"@type":"ListItem","position":3,"name":"Java String Methods with Examples"}]},{"@type":"WebSite","@id":"https:\/\/data-flair.training\/blogs\/#website","url":"https:\/\/data-flair.training\/blogs\/","name":"DataFlair","description":"Learn Today. Lead Tomorrow.","publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/data-flair.training\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/data-flair.training\/blogs\/#organization","name":"DataFlair","url":"https:\/\/data-flair.training\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","width":106,"height":48,"caption":"DataFlair"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DataFlairWS\/","https:\/\/x.com\/DataFlairWS","https:\/\/www.linkedin.com\/company\/dataflair-web-services-pvt-ltd\/","https:\/\/www.youtube.com\/user\/DataFlairWS"]},{"@type":"Person","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/0e594f928e31fc96628ac40f6ae74f49","name":"TechVidvan Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/c89190da3d4010c71ba476b618ab10fdc2335c82cdfa0ad5002d98d0f2473444?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/c89190da3d4010c71ba476b618ab10fdc2335c82cdfa0ad5002d98d0f2473444?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/c89190da3d4010c71ba476b618ab10fdc2335c82cdfa0ad5002d98d0f2473444?s=96&d=mm&r=g","caption":"TechVidvan Team"},"description":"TechVidvan Team provides high-quality content &amp; courses on AI, ML, Data Science, Data Engineering, Data Analytics, programming, Python, DSA, Android, Flutter, full stack web dev, MERN, and many latest technology.","url":"https:\/\/data-flair.training\/blogs\/author\/test001\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/123465","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/users\/86671"}],"replies":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/comments?post=123465"}],"version-history":[{"count":6,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/123465\/revisions"}],"predecessor-version":[{"id":143630,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/123465\/revisions\/143630"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/134207"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=123465"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=123465"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=123465"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}