Java Program to Demo Built-in String Functions

In java programming there are many built-in string manipulation functions.These functions belong to java.lang packages. The Java program to demo built in function use of each commonly used string function .More details about string class will be discussed in our Java Programming Tutorial.


The program is written using NetBean 8.2 and you may also need to install the suitable Java SDK version for NetBean IDE. The operating system platform is Windows 7 64-bit system. The program is a very simple one and intended for beginners of Java programming.

Problem Definition

The program reads 3 string variables and then perform following operations on them.

  • Find the length of the string using length () function.
  • Convert the string into uppercase and lowercase using toUpperCase () and toLowerCase () functions respectively.
  • ┬áConcatenate two strings using concat () function.


Flowchart: Java Program to Demo Built-in String Functions
Flowchart: Java Program to Demo Built-in String Functions

Program Code

 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
package JavaExamples;

* @author Admin
public class StringDemo {

    public static void main(String[] args) {

        int x, y;

        String S = "Elephant";

        String S1 = "Tiger";

        String S3 = "Hello";

        x = S.length();
        y = S1.length();
        System.out.println("Length of S=" + x);
        System.out.println("Length of S1=" + y);

        String S2 = S + S1;

        System.out.println("S2=" + S2);

        String S4 = S3.concat(S1);




The output of the program is given below. It show the various forms of string variable – uppercase, lowercase, concatenated strings and length of strings.

Length of S=8

Length of S1=5



S2 = ElephantTiger


Related Articles:-


Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.