Coders Packet

String manipulations in Java

By Sweta Sinha

In this project we are going to learn about how to use strings or characters in Java. String are the series of characters.


This project is all about string in Java. In Java, main tool for processing and storing language is string class. Strings are constant and cannot be changed. Strings are mainly used in Java programming. For eg:"Sweta" is a string of 5 characters

public class manipulation1
  public static void main(String args[])
    String a="ankit";
    String b="the";
    String c="great goalkeeper";
    String d1= Ankit kumar Pandey";
    String d2= Ankit kumar Pandey";
    String c= Alex Dey";
    System.out.println("The upper case of ankit="+a.toUpperCase());
    System.out.println("After replacing 'h' with 'i' of the="+b.replace('h','i'));
    System.out.println("The string after removing blank spaces="+c.trim());
    System.out.println("The equal string="+d1.equals(d2));
    System.out.println("The length of the string Alex Dey="+e.length());
    System.out.println("The character at 2nd.position="+b.cahrAt(2));
    System.out.println("The concat of the strings="+a.concat(e));

The upper case of ankit= ANKIT
After replacing 'h' with 'i' of the= the
The string after removing blank spaces= great goalkeeper
The equal string= true
The length of the string Alex Dey=7
The character at 2nd.postion= h
Tye concat of the strings= ankitAlex Dey



Download Complete Code


No comments yet