String Manipulations Java Program

String Manipulations Java Program

Java program performs the string manipulations.

In this program, we are using DataInputStream class to read the string inputs and also using string manipulation methods.

import java.io.*;
class Str {
public static void main (String args[])
{
	String a,b,c; 
	int I,p; 
	try {
		java.io.DataInputStream in = new java.io.DataInputStream(System.in);
		System.out.print("\nEnter a String1:"); 
		a=in.readLine(); 
		System.out.print("\nEnter a String2:"); 
		b=in.readLine();
		c=a.concat(b); 
		System.out.println("Concatenated String:"+c); 
		I=a.length(); 
		System.out.println("Lenght of the String:"+c.length()); 
		System.out.println("String in UpperCase:"+c.toUpperCase()); 
		System.out.println("Enter the position to know the character At:"); 
		p=Integer.parseInt(in.readLine()); 
		System.out.println("The Character At that position:"+c.charAt(p-1)); 
	} catch(Exception e) {
	}
}
}

Output:

Enter a String1: test1

Enter a String2:test2
Concatenated String: test1test2
Lenght of the String:11
String in UpperCase: TEST1TEST2
Enter the position to know the character At:
3
The Character At that position:e



Python installation

Privacy Policy  |  Copyrightcopyright symbol2020 - All Rights Reserved.  |  Contact us   |  Report website issues in Github   |  Facebook page   |  Google+ page

Email Facebook Google LinkedIn Twitter
^