String in java .
In this program we will know the operations of String in java,So lets make a program to show the operations of String.
import java.util.Scanner; public class Stringob { public static void main(String[] args) { String s1,s2; int l1,l2; Scanner t =new Scanner(System.in); System.out.println("enter first strings:"); s1 = t.nextLine(); System.out.println("enter second strings:"); s2=t.nextLine(); String s3=s1.concat(s2); // concatinating.. l1=s3.length(); System.out.println("Concatination reasult will : " +s3); System.out.println("length of strings: " + l1); // More operations on string : String s4=new String("More operation on string.."); System.out.println(": " + s4); char s5[] = {'A','N','U','R','A','G'}; String s6=new String(s5); System.out.println(": Combine form is: " + s6); String s7=new String(s5,2,3); // s5(destination),2(starting point),3(taken element). System.out.println(": " + s7); } }
Now, run the program and see output.:
Output:
Happy coding..