• 17 May

    How to check if one String is rotation of another String in java

    In this post, we will see how to check if one String is rotation of another or not. For example: java2blog and blogjava2 are rotation of each other. java2blog and avablog2j are not rotation of each other. Approach: Lets say you need to check whether str1 and str2 is rotation of one another or not. […]

  • 17 May

    Can we call run() method directly to start a new thread

    No, you can not directly call run method to start a thread. You need to call start method to create a new thread. If you call run method directly , it won’t create a new thread and it will be in same stack as main. Lets understand with the help of example: package org.arpit.java2blog; class […]

  • 16 May

    Can we start a thread twice in java

    No, Once you have started a thread, it can not be started again. If you try to start thread again , it will throw IllegalThreadStateException Lets understand with the help of example: package org.arpit.java2blog; class FirstThread extends Thread { public void run() { System.out.println("Thread is running"); } } public class StartThreadAgainMain { public static void […]

  • 15 May

    Java String compareToIgnoreCase example

    String’s compareToIgnoreCase method is similar to compareTo method. Only difference with compareTo is that it ignores cases.It also compares Strings lexigraphically. Both String get converted to unicode value and then compares. If you call str1. compareToIgnoreCase(str2) then if it returns positive number : str1 is greater than str2 0: str1 is equal to str2 negative number : str1 is […]

  • 15 May

    Ghid practic pentru casino online 777 – Cum să începi și să câștigi

    777 casino ro se remarcă pe o piață competitivă, iar acest ghid pas cu pas explică exact cum să profiți la maximum de el. Fie că ești la primul contact cu un cazino online 777 sau ai deja experiență, următoarele informații te vor ajuta să navighezi eficient, să revendici bonusuri și să gestionezi eventualele probleme. […]

  • 14 May

    Java String equalsIgnoreCase example

    String’s equalsIgnoreCase method is similar to equals method but it ignores case. So if Strings have different cases, then also it will considered as equals. For example: String str1="Java2blog.com" String str2="JAVA2BLOG.COM" str1.equalsIgnoreCase(str2) will return true. Method Signature: public boolean equalsIgnoreCase(Object anObject) String equalsIgnoreCase Example: package org.arpit.java2blog; public class StringEqualsExamplesMain { public static void main(String[] args) […]

  • 14 May

    Java String equals example

    String’s equals method compares String with specified object. It checks if both have same character sequence. It is generally used to compare two Strings. Method Signature: public boolean equals(Object anObject) String equals Example: package org.arpit.java2blog; public class StringEqualsExamplesMain { public static void main(String[] args) { String str1 = "Hello world from java2blog.com"; String str2 = […]

  • 14 May

    Java String contentEquals example

    String’s contentEquals method is used to compare String with StringBuffer. It returns boolean datatype. Method syntax: public boolean contentEquals(StringBuffer sb) String contentEquals Example: package org.arpit.java2blog; public class StringContentEqualsExample { public static void main(String[] args) { String str1 = "java2blog"; String str2="Hello world from java2blog"; String str3="JAVA2BLOG"; StringBuffer sb=new StringBuffer("java2blog"); System.out.println(str1.contentEquals(sb)); System.out.println(str2.contentEquals(sb)); System.out.println(str3.contentEquals(sb)); } } When […]

  • 13 May

    Java String endsWith example

    String’s endWith method checks if String ends with specific suffix. It returns boolean datatype. Method syntax: public boolean endsWith(String suffix) String endsWith Example: package org.arpit.java2blog; public class StringEndsWithExample { public static void main(String[] args) { String str = "java2blog"; if (str.endsWith("blog")) { System.out.println("String ends with blog"); } else { System.out.println("String does not end with blog"); […]

Subscribe to our newletter

Get quality tutorials to your inbox. Subscribe now.