{"id":76471,"date":"2020-02-15T10:07:27","date_gmt":"2020-02-15T04:37:27","guid":{"rendered":"https:\/\/techvidvan.com\/tutorials\/?p=76471"},"modified":"2020-02-15T10:07:27","modified_gmt":"2020-02-15T04:37:27","slug":"java-strings","status":"publish","type":"post","link":"https:\/\/techvidvan.com\/tutorials\/java-strings\/","title":{"rendered":"Java Strings &#8211; Learn the Essential Methods with its Syntax!"},"content":{"rendered":"<p>A String is defined as a sequence or an array of characters. We have already covered the basics of String in our article <em><strong>Java Data types<\/strong><\/em>. We know that String in Java is not a primitive data type; instead, it is an object of class String.<\/p>\n<p>Java Strings are one of the most common and widely used classes in Java programming. The String is an array of characters, and since arrays are immutable in nature, a String is an immutable object, which means they are constant, and we cannot change them after creating the objects.<\/p>\n<p>In this tutorial, we will learn the Java Strings in-depth with the help of the Java Wrapper class &#8211; String class.<\/p>\n<h3>Working with Strings in Java<\/h3>\n<p>Strings are a group of characters. In Java, you can work with the character data that is, a single character or a group of characters (Strings) in 4 different ways:<\/p>\n<h4>Character Class<\/h4>\n<p>It is a wrapper class whose objects hold single character data.<\/p>\n<h4>String Class<\/h4>\n<p>It is a class whose instances or objects can hold the unchanging or constant string (immutable String).<\/p>\n<h4>StringBuffer Class<\/h4>\n<p>Its instances or objects can hold mutable strings that can be changed or modified.<\/p>\n<h4>StringBuilder Class<\/h4>\n<p>Java StringBuilder class is similar to the StringBuffer class which holds a sequence of mutable Strings but is more versatile than StringBuffer class because it provides more modification features.<\/p>\n<h3>Creating Strings in Java<\/h3>\n<p>There are 2 ways of creating a String object:<\/p>\n<h4>By using a string literal<\/h4>\n<p>It is the most common way to create a String. Java String literal can be created just by using double-quotes.<\/p>\n<p><strong>For example &#8211;<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">String line = \u201cWelcome to TechVidvan Java Tutorial\u201d ;<\/pre>\n<p>Through this line, the compiler creates a String object in a String Pool with its value<em> \u201cWelcome to TechVidvan Java Tutorial\u201d.<\/em><\/p>\n<h4>By using a \u201cnew\u201d keyword<\/h4>\n<p>Java String can also be created by using a new keyword with the String constructor.<\/p>\n<p><strong> For example &#8211;<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">String line = new String(\u201cWelcome to TechVidvan Java Tutorial\u201d);<\/pre>\n<p><strong>Code Snippet to understand the ways to create a string &#8211;<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">package com.TechVidvan.StringDemo;\npublic class StringTutorial\n{\n  public static void main(String args[])\n  {\n    String string1 = \"Hello World\";\n    \/\/ declaring string using string literals\n    String string2 = new String(\"This is TechVidvan Java Tutorial \");\n\n    \/\/declaring string using the new operator\n    System.out.println(string1);\n    System.out.println(string2);\n  }\n}<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">Hello World<br \/>\nThis is TechVidvan Java Tutorial<\/div>\n<h3>Creating StringBuffers<\/h3>\n<p>StringBuffer objects are always created with a <strong>new<\/strong> operator. There are three ways by which you can create StringBuffer Objects:<\/p>\n<h4>1. Creating an empty StringBuffer object<\/h4>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">StringBuffer sBuffer = new StringBuffer() ;<\/pre>\n<h4>2. Creating and initializing the StringBuffer object<\/h4>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">StringBuffer sBuffer = new StringBuffer( \u201c Hello World \u201d ) ;<\/pre>\n<h4>3. Creating a StringBuffer object with an initial capacity equal to n<\/h4>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">int n= 15;\nStringBuffer sBuffer = new StringBuffer( n ) ;<\/pre>\n<p>Here, n is equal to 15 which is the number of characters. The object sBuffer has the capacity to hold 15 number of characters.<\/p>\n<h3>Methods of Java String Class<\/h3>\n<p>The methods of String class are used to obtain information about objects and are known as accessor methods. The <strong>String class<\/strong> provides many accessor methods that are used to perform operations on strings. We will cover some important methods of the String class in detail with the help of examples and code.<\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/02\/methods-of-java-string.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-76619\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/02\/methods-of-java-string.jpg\" alt=\"Java String Methods\" width=\"802\" height=\"420\" \/><\/a><\/p>\n<h4>1. int length() method<\/h4>\n<p>The length() method returns the length of the String that is, the number of characters in a String.<\/p>\n<p><strong>Syntax:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">stringName.length( ) ;<\/pre>\n<p><strong>Code to illustrate the use of length() method:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">package com.TechVidvan.StringDemo;\npublic class LengthOfString\n{\n  public static void main(String args[])\n  {\n    String sentence = \"This is a Tutorial on Strings\";\n    int len = sentence.length();\n    System.out.println( \"Length of sentence is : \" + len );\n  }\n}<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">Length of sentence is : 29<\/div>\n<p><strong>Note:<\/strong> The length() method also includes whitespaces in the strings to calculate the length of the string.<\/p>\n<h4>2. char charAt(int index) method<\/h4>\n<p>We use charAt method to return a character value at a specified position (index) of a String.<\/p>\n<p><strong>Syntax:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">stringName.charAt( index ) ;<\/pre>\n<p><strong>Code to illustrate the use of charAt() method<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">package com.TechVidvan.StringDemo;\npublic class CharacterAtPosition\n{\n  public static void main(String args[])\n  {\n           String sentence = \"Tech Vidvan\";\n           char result = sentence.charAt(8);\n           System.out.println(\"At position 8, the character is: \" +result);\n           System.out.println(\"At position 1, the character is: \" +sentence.charAt(1));\n  }\n}<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">At position 8, the character is: v<br \/>\nAt position 1, the character is: e<\/div>\n<h4>3. String concat(String string1) method<\/h4>\n<p>The method concat() is used for concatenating or adding two strings into a single string. This method appends its String argument to the indicated string argument and returns a new instance of the String class.<\/p>\n<p><strong>Syntax:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">string1.concat(string2);<\/pre>\n<p><strong>Code to illustrate the use of the concat() method:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">package com.TechVidvan.StringDemo;\npublic class StringConcatenation\n{\n  public static void main(String args[])\n  {\n    String string1 = \"Tech Vidvan \";\n    String string2 = \"Java Tutorial\";\n    string1 = string1.concat(string2);\n    System.out.println(\"Concatenated String is: \" +string1);\n  }\n}<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">Concatenated String is: Tech Vidvan Java Tutorial<\/div>\n<p>We can also use the <strong>+ operator<\/strong> to produce the same result as the concat method:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">package com.TechVidvan.StringDemo;\npublic class StringConcatenation\n{\n  public static void main(String args[])\n  {\n    String string1 = \"Tech Vidvan \";\n    String string2 = \"Java Tutorial\";\n    string1 = string1 + string2;\n    System.out.println(\"Concatenated String is: \" +string1);\n  }\n}<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">Concatenated String is: Tech Vidvan Java Tutorial<\/div>\n<h4>4. String substring(int beginIndex) method<\/h4>\n<p>The substring method with a single argument is used to create new objects or instances of String class from existing instances of String. The method returns the substring from the index which is passed as an argument to the method.<\/p>\n<p><strong>Syntax:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">sentence.substring(beginIndex) ;<\/pre>\n<p><strong>Code to illustrate the use of the substring(int index) method:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">package com.TechVidvan.StringDemo;\npublic class SubStrings\n{\n  public static void main(String args[])\n  {\n    String sentence = \"Welcome to TechVidvan Tutorial on Strings\";\n    String subString = sentence.substring(11);\n    System.out.println( \"The Substring is: \" +subString) ;\n  }\n}<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">The Substring is: TechVidvan Tutorial on Strings<\/div>\n<h4>5. String substring(int beginIndex, int endIndex) method<\/h4>\n<p>The substring with two arguments method is used to create new objects or instances of String class from existing instances of String. The method returns the new String by using the required index range (including the start index and excluding the end index).<\/p>\n<p><strong>Syntax:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">sentence.substring(beginIndex, endIndex) ;<\/pre>\n<p><strong>Code to illustrate the use of the substring(beginIndex, endIndex) method:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">package com.TechVidvan.StringDemo;\npublic class SubStrings\n{\n  public static void main(String args[])\n  {\n    String sentence = \"Welcome to TechVidvan Tutorial on Strings\";\n    String subString1 = sentence.substring(11, 21);\n    String subString2 = sentence.substring(22, 30);\n    System.out.println(\"The Substring within the range is: \" + subString1);\n    System.out.println(\"The Substring within the range is: \" + subString2);\n  }\n}<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">The Substring within the range is: TechVidvan<br \/>\nThe Substring within the range is: Tutorial<\/div>\n<h4>6. int compareTo(String string1, String string2) method<\/h4>\n<p>When we use the compareTo() method, the method returns an integer which indicates the lexicographic (alphabetical) comparison of the two strings.<\/p>\n<p>The result is <strong>negative<\/strong> if the relative alphabetic value of the particular letter of the first string is smaller than that of the second string\u2019s letter on the same location. And it is<strong> positive<\/strong> if the first string is lexicographically larger than the second string.<\/p>\n<p>If both strings are identical, then a value <strong>zero(0)<\/strong> is returned.<\/p>\n<p><strong>Syntax:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">string1.compareTo(string2) ;<\/pre>\n<p><strong>Code to illustrate the use of the concat(string1, string2) method:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">package com.TechVidvan.StringDemo;\npublic class CompareStrings\n{\n  public static void main(String args[])\n  {\n    String string1 = \"Hello World\";\n    String string2 = \"Hello World\";\n    int result = string1.compareTo(string2);\n    System.out.println(result);\n\n    String sentence = \"Welcome \";\n    result = sentence.compareTo(\"to TechVidvan Tutorial \");\n    System.out.println(result);\n\n    String sentence1 = \"This is a \";\n    String sentence2 = \"Java Tutorial \";\n    result = sentence1.compareTo(sentence2);\n    System.out.println(result);\n  }\n}<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">0<br \/>\n-29<br \/>\n10<\/div>\n<h4>7. String toUpperCase() method<\/h4>\n<p>The method toUpperCase() converts all the characters of a given string to uppercase.<\/p>\n<p><strong>Syntax:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">sentence.toUpperCase() ;<\/pre>\n<p><strong>Code to illustrate the use of the toUpperCase() method:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">package com.TechVidvan.StringDemo;\npublic class CaseConversion\n{\n  public static void main(String args[])\n  {\n    String string1 = \"Hello World\";\n    String string2 = \"welcome to TechVidvan\";\n    System.out.println(string1.toUpperCase());\n    System.out.println(string2.toUpperCase());\n  }\n}<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">HELLO WORLD<br \/>\nWELCOME TO TECHVIDVAN<\/div>\n<h4>8. String toLowerCase() method<\/h4>\n<p>The method toLowerCase() converts all the characters of a given string to lowercase.<\/p>\n<p><strong>Syntax:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">sentence.toLowerCase() ;<\/pre>\n<p><strong>Code to illustrate the use of the toLowerCase() method:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">package com.TechVidvan.StringDemo;\npublic class CaseConversion\n{\n  public static void main(String args[])\n  {\n    String string1 = \"HELLO WORLD\";\n    String string2 = \"WELCOME TO TECHVIDVAN\";\n    System.out.println(string1.toLowerCase());\n    System.out.println(string2.toLowerCase());\n  }\n}<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">hello world<br \/>\nwelcome to techvidvan<\/div>\n<h4>9. String trim() method<\/h4>\n<p>This method returns the new String after removing whitespaces at both ends. It does not affect whitespaces in the middle of the String.<\/p>\n<p><strong>Syntax:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">sentence.trim() ;<\/pre>\n<p><strong>Code to illustrate the use of the trim() method:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">package com.TechVidvan.StringDemo;\npublic class TrimString\n{\n  public static void main(String args[])\n  {\n    String string1 = \" This is a Tutorial on Strings \";\n    System.out.println(\"The original string is:\" +string1);\n    System.out.println(\"The trimmed string is:\" +string1.trim());\n  }\n}<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">The original string is: This is a Tutorial on Strings<br \/>\nThe trimmed string is:This is a Tutorial on Strings<\/div>\n<h4>10. String replace(char oldChar, char newChar)<\/h4>\n<p>This method replaces each occurrence of the first argument of the string with the second argument and returns the resulting string.<\/p>\n<p><strong>Syntax:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">sentence.replace(char1, char2) ;<\/pre>\n<p><strong>Code to illustrate the use of the trim() method:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">package com.TechVidvan.StringDemo;\npublic class ReplaceString\n{\n  public static void main(String args[])\n  {\n       \/\/Replacing all the 'a' with 'e'\n        String string1=\"TechVidvan is a good tutorial\";\n       String replaceString=string1.replace('a','e');\n            \/\/replaces all occurrences of 'a' to 'e'\n             System.out.println(\"String after replacing characters is: \" +replaceString);\n\n  }\n}<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">String after replacing characters is: TechVidven is e good tutoriel<\/div>\n<h3>Summary<\/h3>\n<p>Strings play a very important role in Java programming. Java provides a String class to manipulate and perform operations on strings. In this article, we have studied the String class which belongs to java.lang package.<\/p>\n<p>We also covered the essential methods useful while dealing with Strings along with their syntax and sample codes. This article will help you in writing Java programs related to Strings.<\/p>\n<p>Thank you for reading our article. Do share our article on Social Media.<\/p>\n<p>Happy Learning \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A String is defined as a sequence or an array of characters. We have already covered the basics of String in our article Java Data types. We know that String in Java is not&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":76619,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[183],"tags":[1709,1710,1711,1595,1704,1712,1713,1714],"class_list":["post-76471","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java","tag-creating-java-strings","tag-creating-stringbuffer","tag-java-string-class","tag-java-strings","tag-java-wrapper-class","tag-methods-in-java-strings","tag-strings-in-java","tag-working-with-java-strings"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Java Strings - Learn the Essential Methods with its Syntax! - TechVidvan<\/title>\n<meta name=\"description\" content=\"Explore the concept of Java Strings in detail along with the different methods of strings in Java with syntax. And learn how to work with strings in Java.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/techvidvan.com\/tutorials\/java-strings\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Java Strings - Learn the Essential Methods with its Syntax! - TechVidvan\" \/>\n<meta property=\"og:description\" content=\"Explore the concept of Java Strings in detail along with the different methods of strings in Java with syntax. And learn how to work with strings in Java.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/techvidvan.com\/tutorials\/java-strings\/\" \/>\n<meta property=\"og:site_name\" content=\"TechVidvan\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/TechVidvan\/\" \/>\n<meta property=\"article:published_time\" content=\"2020-02-15T04:37:27+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/02\/methods-of-java-string.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"802\" \/>\n\t<meta property=\"og:image:height\" content=\"420\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"TechVidvan Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:site\" content=\"@vidvantech\" \/>\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=\"8 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Java Strings - Learn the Essential Methods with its Syntax! - TechVidvan","description":"Explore the concept of Java Strings in detail along with the different methods of strings in Java with syntax. And learn how to work with strings in Java.","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:\/\/techvidvan.com\/tutorials\/java-strings\/","og_locale":"en_US","og_type":"article","og_title":"Java Strings - Learn the Essential Methods with its Syntax! - TechVidvan","og_description":"Explore the concept of Java Strings in detail along with the different methods of strings in Java with syntax. And learn how to work with strings in Java.","og_url":"https:\/\/techvidvan.com\/tutorials\/java-strings\/","og_site_name":"TechVidvan","article_publisher":"https:\/\/www.facebook.com\/TechVidvan\/","article_published_time":"2020-02-15T04:37:27+00:00","og_image":[{"width":802,"height":420,"url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/02\/methods-of-java-string.jpg","type":"image\/jpeg"}],"author":"TechVidvan Team","twitter_card":"summary_large_image","twitter_creator":"@vidvantech","twitter_site":"@vidvantech","twitter_misc":{"Written by":"TechVidvan Team","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/techvidvan.com\/tutorials\/java-strings\/#article","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/java-strings\/"},"author":{"name":"TechVidvan Team","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22"},"headline":"Java Strings &#8211; Learn the Essential Methods with its Syntax!","datePublished":"2020-02-15T04:37:27+00:00","mainEntityOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/java-strings\/"},"wordCount":1134,"commentCount":0,"publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/java-strings\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/02\/methods-of-java-string.jpg","keywords":["Creating Java Strings","Creating StringBuffer","Java String Class","java strings","Java Wrapper class","Methods in Java Strings","Strings in Java","Working with Java Strings"],"articleSection":["Java Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/techvidvan.com\/tutorials\/java-strings\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/techvidvan.com\/tutorials\/java-strings\/","url":"https:\/\/techvidvan.com\/tutorials\/java-strings\/","name":"Java Strings - Learn the Essential Methods with its Syntax! - TechVidvan","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/#website"},"primaryImageOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/java-strings\/#primaryimage"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/java-strings\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/02\/methods-of-java-string.jpg","datePublished":"2020-02-15T04:37:27+00:00","description":"Explore the concept of Java Strings in detail along with the different methods of strings in Java with syntax. And learn how to work with strings in Java.","breadcrumb":{"@id":"https:\/\/techvidvan.com\/tutorials\/java-strings\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/techvidvan.com\/tutorials\/java-strings\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/java-strings\/#primaryimage","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/02\/methods-of-java-string.jpg","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/02\/methods-of-java-string.jpg","width":802,"height":420,"caption":"Java String Methods"},{"@type":"BreadcrumbList","@id":"https:\/\/techvidvan.com\/tutorials\/java-strings\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/techvidvan.com\/tutorials\/"},{"@type":"ListItem","position":2,"name":"Java Strings &#8211; Learn the Essential Methods with its Syntax!"}]},{"@type":"WebSite","@id":"https:\/\/techvidvan.com\/tutorials\/#website","url":"https:\/\/techvidvan.com\/tutorials\/","name":"TechVidvan Blogs","description":"","publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/techvidvan.com\/tutorials\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/techvidvan.com\/tutorials\/#organization","name":"TechVidvan","url":"https:\/\/techvidvan.com\/tutorials\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","width":200,"height":50,"caption":"TechVidvan"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/TechVidvan\/","https:\/\/x.com\/vidvantech"]},{"@type":"Person","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22","name":"TechVidvan Team","description":"The TechVidvan Team delivers practical, beginner-friendly tutorials on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our experts are here to help you upskill and excel in today\u2019s tech industry."}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/76471","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/comments?post=76471"}],"version-history":[{"count":0,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/76471\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media\/76619"}],"wp:attachment":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media?parent=76471"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/categories?post=76471"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/tags?post=76471"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}