JAVA STRING PROGRAM


JAVA String Programs | Core Java Tutorial | Minigranth

Java String Programs

  • Java string programs are quiet easy to write only when you practice a lot.
  • While learning Strings in Java you may encounter many programming problems like solved above. These were some common java string programs that you might get in your exams.
  1. Java String Programs to Check whether a string is palindrome or not.

    • A palindrome string is that string which when reversed is same as original string. For example :  “aba”  is a palindrome whereas “abc” is not.
    • Hence we can use here reverse() function of StringBuffer or StringBuilder class.

    • Java String Programs to Check whether a string is palindrome or not.
      Program

      Java String Programs to Check whether a string is palindrome or not output.
      Output

  2. Java String Programs to print the following pattern.

    S

    S T

    S T R

    S T R I

    S T R I N

    S T R I N G

    Programs to print the following pattern.
    Program


    Output

  3. Java String Programs to toggle the case of characters in String. Uppercase character in string should be converted to lower case and lowercase character to upper case.

    • An example can be, If the input string is "MIniGraNTh" , then Output will be "miNIgRAntH"

    • Java String Programs to toggle the case of characters in String. Uppercase character in string should be converted to lower case and lowercase character to upper case.
      Program


      Output

  4. Java String Programs to reverse every word of a sentence.

    • Input : This is Minigranth
    • Output : sihT si htnarginiM

    • Programs to reverse every word of a sentence.
      Program


      Output

  5. Java String Programs to print longest word in a sentence.

    • Input : Today is pleasant weather
    • Output : Longest Word = pleasant

    • Java String Programs to print longest word in a sentence.
      Program


      Output

Note : That's all about core java. Thank you for being such a patient audience and for following all the way along from first chapter to this chapter. We will add some more chapters very soon and will also add advance java. Till then you can practice your skills on mock test provided by minigranth and you can visit the official documentation.