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.
STRING MANIPULATIONS IN JAVA
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
import java.io.*; 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)); } } Output: 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
.
Submitted by Sweta Sinha (Sweta321)
Download packets of source code on Coders Packet
Comments