{"id":26982,"date":"2021-05-07T23:10:06","date_gmt":"2021-05-08T03:10:06","guid":{"rendered":"http:\/\/bangla.salearningschool.com\/recent-posts\/stringtest-java-demonstrates-various-methods-of-the-string-class-programming-code-examples-java-j2ee-j2me-basic-java\/"},"modified":"2021-05-07T23:10:06","modified_gmt":"2021-05-08T03:10:06","slug":"stringtest-java-demonstrates-various-methods-of-the-string-class-programming-code-examples-java-j2ee-j2me-basic-java","status":"publish","type":"post","link":"http:\/\/bangla.sitestree.com\/?p=26982","title":{"rendered":"StringTest.java Demonstrates various methods of the String class. #Programming Code Examples #Java\/J2EE\/J2ME #Basic Java"},"content":{"rendered":"<pre>\n\/** Taken from Core Web Programming from\n *  Prentice Hall and Sun Microsystems Press,\n *  .\n *  &copy; 2001 Marty Hall and Larry Brown;\n *  may be freely used or adapted.\n *\/\n\n\n  public class StringTest {\n  public static void main (String[] args) {\n    String str = &quot;&quot;;\n    if (args.length &gt; 0) {\n        str = args[0];\n    }\n    if (str.length()&gt;8) {\n      System.out.println(&quot;String is &quot;&quot; + str + &quot;&quot;n&quot;);\n      System.out.println(&quot;  charAt(3) ------------------ &quot; +\n                         str.charAt(3));\n      System.out.println(&quot;  compareTo(Moscow) ---------- &quot; +\n                         str.compareTo(&quot;Moscow&quot;));\n      System.out.println(&quot;  concat(SuFFiX) ------------- &quot; +\n                         str.concat(&quot;SuFFiX&quot;));\n      System.out.println(&quot;  endsWith(hic) -------------- &quot; +\n                         str.endsWith(&quot;hic&quot;));\n      System.out.println(&quot;  == Geographic -------------- &quot; +\n                         (str == &quot;Geographic&quot;));\n      System.out.println(&quot;  equals(geographic) --------- &quot; +\n                         str.equals(&quot;geographic&quot;));\n      System.out.println(&quot;  equalsIgnoreCase(geographic) &quot; +\n                         str.equalsIgnoreCase(&quot;geographic&quot;));\n      System.out.println(&quot;  indexOf('o') --------------- &quot; +\n                         str.indexOf('o'));\n      System.out.println(&quot;  indexOf('i',5) ------------- &quot; +\n                         str.indexOf('i',5));\n      System.out.println(&quot;  indexOf('o',5) ------------- &quot; +\n                         str.indexOf('o',5));\n      System.out.println(&quot;  indexOf(rap) --------------- &quot; +\n                         str.indexOf(&quot;rap&quot;));\n      System.out.println(&quot;  indexOf(rap, 5) ------------ &quot; +\n                         str.indexOf(&quot;rap&quot;, 5));\n      System.out.println(&quot;  lastIndexOf('o') ----------- &quot; +\n                         str.lastIndexOf('o'));\n      System.out.println(&quot;  lastIndexOf('i',5) --------- &quot; +\n                         str.lastIndexOf('i',5));\n      System.out.println(&quot;  lastIndexOf('o',5) --------- &quot; +\n                         str.lastIndexOf('o',5));\n      System.out.println(&quot;  lastIndexOf(rap) ----------- &quot; +\n                         str.lastIndexOf(&quot;rap&quot;));\n      System.out.println(&quot;  lastIndexOf(rap, 5) -------- &quot; +\n                         str.lastIndexOf(&quot;rap&quot;, 5));\n      System.out.println(&quot;  length() ------------------- &quot; +\n                         str.length());\n      System.out.println(&quot;  replace('c','k') ----------- &quot; +\n                         str.replace('c','k'));\n      System.out.println(&quot;  startsWith(eog,1) ---------- &quot; +\n                         str.startsWith(&quot;eog&quot;,1));\n      System.out.println(&quot;  startsWith(eog) ------------ &quot; +\n                         str.startsWith(&quot;eog&quot;));\n      System.out.println(&quot;  substring(3) --------------- &quot; +\n                         str.substring(3));\n      System.out.println(&quot;  substring(3,8) ------------- &quot; +\n                         str.substring(3,8));\n      System.out.println(&quot;  toLowerCase() -------------- &quot; +\n                         str.toLowerCase());\n      System.out.println(&quot;  toUpperCase() -------------- &quot; +\n                         str.toUpperCase());\n      System.out.println(&quot;  trim() --------------------- &quot; +\n                         str.trim());\n      System.out.println(&quot;nString is still &quot;&quot; + str + &quot;&quot;n&quot;);\n    }\n  }\n}\n<\/pre>\n<p>Note: Brought from our old site: http:\/\/www.salearningschool.com\/example_codes\/ on Jan 2nd, 2017 From: http:\/\/sitestree.com\/?p=10225<br \/> Categories:Programming Code Examples, Java\/J2EE\/J2ME, Basic Java<br \/>Tags:Java\/J2EE\/J2MEBasic Java<br \/> Post Data:2017-01-02 16:04:28<\/p>\n<p>\t\tShop Online: <a href='https:\/\/www.ShopForSoul.com\/' target='new' rel=\"noopener\">https:\/\/www.ShopForSoul.com\/<\/a><br \/>\n\t\t(Big Data, Cloud, Security, Machine Learning): Courses: <a href='http:\/\/Training.SitesTree.com' target='new' rel=\"noopener\"> http:\/\/Training.SitesTree.com<\/a><br \/>\n\t\tIn Bengali: <a href='http:\/\/Bangla.SaLearningSchool.com' target='new' rel=\"noopener\">http:\/\/Bangla.SaLearningSchool.com<\/a><br \/>\n\t\t<a href='http:\/\/SitesTree.com' target='new' rel=\"noopener\">http:\/\/SitesTree.com<\/a><br \/>\n\t\t8112223 Canada Inc.\/JustEtc: <a href='http:\/\/JustEtc.net' target='new' rel=\"noopener\">http:\/\/JustEtc.net (Software\/Web\/Mobile\/Big-Data\/Machine Learning) <\/a><br \/>\n\t\tShop Online: <a href='https:\/\/www.ShopForSoul.com'> https:\/\/www.ShopForSoul.com\/<\/a><br \/>\n\t\tMedium: <a href='https:\/\/medium.com\/@SayedAhmedCanada' target='new' rel=\"noopener\"> https:\/\/medium.com\/@SayedAhmedCanada <\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\/** Taken from Core Web Programming from * Prentice Hall and Sun Microsystems Press, * . * &copy; 2001 Marty Hall and Larry Brown; * may be freely used or adapted. *\/ public class StringTest { public static void main (String[] args) { String str = &quot;&quot;; if (args.length &gt; 0) { str = args[0]; &hellip; <\/p>\n<p><a class=\"more-link btn\" href=\"http:\/\/bangla.sitestree.com\/?p=26982\">Continue reading<\/a><\/p>\n","protected":false},"author":8,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1917],"tags":[],"class_list":["post-26982","post","type-post","status-publish","format-standard","hentry","category-fromsitestree-com","item-wrap"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":10517,"url":"http:\/\/bangla.sitestree.com\/?p=10517","url_meta":{"origin":26982,"position":0},"title":"StringTest.java Demonstrates various methods of the String class.","author":"","date":"August 29, 2015","format":false,"excerpt":"\/** Taken from Core Web Programming from \u00a0*\u00a0 Prentice Hall and Sun Microsystems Press, \u00a0*\u00a0 . \u00a0*\u00a0 \u00a9 2001 Marty Hall and Larry Brown; \u00a0*\u00a0 may be freely used or adapted. \u00a0*\/ \u00a0 public class StringTest { \u00a0 public static void main (String[] args) { \u00a0\u00a0\u00a0 String str = \"\";\u2026","rel":"","context":"In &quot;Code . Programming Samples . \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae \u0989\u09a6\u09be\u09b9\u09b0\u09a8&quot;","block_context":{"text":"Code . Programming Samples . \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae \u0989\u09a6\u09be\u09b9\u09b0\u09a8","link":"http:\/\/bangla.sitestree.com\/?cat=1417"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":26864,"url":"http:\/\/bangla.sitestree.com\/?p=26864","url_meta":{"origin":26982,"position":1},"title":"Example Java Programs #Programming Code Examples #Java\/J2EE\/J2ME #J2SE","author":"Author-Check- Article-or-Video","date":"May 3, 2021","format":false,"excerpt":"Very Simple Java Example Programs HelloWorld.java public class HelloWorld { \/\/ method main(): ALWAYS the APPLICATION entry point public static void main (String[] args) { System.out.println (\"Hello World!\"); } } \/\/ Print Today's Date import java.util.*; public class HelloDate { public static void main (String[] args) { System.out.println (\"Hello, it's:\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":10104,"url":"http:\/\/bangla.sitestree.com\/?p=10104","url_meta":{"origin":26982,"position":2},"title":"Example Java Programs","author":"","date":"August 3, 2015","format":false,"excerpt":"HelloWorld.java public class HelloWorld { \u00a0\u00a0\u00a0 \/\/ method main(): ALWAYS the APPLICATION entry point \u00a0\u00a0\u00a0 public static void main (String[] args) { \u00a0\u00a0 \u00a0System.out.println (\"Hello World!\"); \u00a0\u00a0\u00a0 } } \/\/ Print Today's Date import java.util.*; public class HelloDate { \u00a0\u00a0\u00a0 public static void main (String[] args) { \u00a0\u00a0 \u00a0System.out.println (\"Hello,\u2026","rel":"","context":"In &quot;Code . Programming Samples . \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae \u0989\u09a6\u09be\u09b9\u09b0\u09a8&quot;","block_context":{"text":"Code . Programming Samples . \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae \u0989\u09a6\u09be\u09b9\u09b0\u09a8","link":"http:\/\/bangla.sitestree.com\/?cat=1417"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":10194,"url":"http:\/\/bangla.sitestree.com\/?p=10194","url_meta":{"origin":26982,"position":3},"title":"UrlRetriever2.java Illustrates how the URL class can simplify communication to an HTTP server.","author":"","date":"August 25, 2015","format":false,"excerpt":"UrlRetriever2.java\u00a0 Illustrates how the URL class can simplify communication to an HTTP server. import java.net.*; import java.io.*; \/** Read a remote file using the standard URL class \u00a0*\u00a0 instead of connecting explicitly to the HTTP server. \u00a0* \u00a0*\u00a0 Taken from Core Web Programming from \u00a0*\u00a0 Prentice Hall and Sun Microsystems\u2026","rel":"","context":"In &quot;Code . Programming Samples . \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae \u0989\u09a6\u09be\u09b9\u09b0\u09a8&quot;","block_context":{"text":"Code . Programming Samples . \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae \u0989\u09a6\u09be\u09b9\u09b0\u09a8","link":"http:\/\/bangla.sitestree.com\/?cat=1417"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":10505,"url":"http:\/\/bangla.sitestree.com\/?p=10505","url_meta":{"origin":26982,"position":4},"title":"Tests the class type of an object using the isInstance method (preferred over instanceof operator).","author":"","date":"August 29, 2015","format":false,"excerpt":"\/** Taken from Core Web Programming from \u00a0*\u00a0 Prentice Hall and Sun Microsystems Press, \u00a0*\u00a0 . \u00a0*\u00a0 \u00a9 2001 Marty Hall and Larry Brown; \u00a0*\u00a0 may be freely used or adapted. \u00a0*\/ interface Barking {} class Mammal {} class Canine extends Mammal {} class Dog extends Canine implements Barking {}\u2026","rel":"","context":"In &quot;Code . Programming Samples . \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae \u0989\u09a6\u09be\u09b9\u09b0\u09a8&quot;","block_context":{"text":"Code . Programming Samples . \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae \u0989\u09a6\u09be\u09b9\u09b0\u09a8","link":"http:\/\/bangla.sitestree.com\/?cat=1417"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":26593,"url":"http:\/\/bangla.sitestree.com\/?p=26593","url_meta":{"origin":26982,"position":5},"title":"UrlRetriever2.java  Illustrates how the URL class can simplify communication to an HTTP server. #Programming Code Examples #Java\/J2EE\/J2ME #Network Programming","author":"Author-Check- Article-or-Video","date":"April 29, 2021","format":false,"excerpt":"UrlRetriever2.java Illustrates how the URL class can simplify communication to an HTTP server. import java.net.*; import java.io.*; \/** Read a remote file using the standard URL class * instead of connecting explicitly to the HTTP server. * * Taken from Core Web Programming from * Prentice Hall and Sun Microsystems\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/26982","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=26982"}],"version-history":[{"count":0,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/26982\/revisions"}],"wp:attachment":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=26982"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=26982"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=26982"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}