Strings:
~~~~~~~
Hello ,Now I like to share about the concept Strings. In JAVA we can perform the string operation using the class String(java.lang.String)w can perform the operations such as conversion the string from lowercase to uppercase and string concatenation, trimming etc using its default functions of String class.
//PROGRAM TO PERFORM STRING OPERATIONS
public class b
{
public static void main(String[] args)
{
String a="JAVA";//declaration of string
String b="INTERPRETERS";
int c=a.length();//TO FIND LENGTH OF GIVEN STRING JAVA USING "length function"
String d=a.concat(b);//here "JAVA" IS CONCAT WITH "INTERPRETERS"
char e=b.charAt(2);//returns the character at 2nd position of string
String f=a.toLowerCase();//converts the upper cased to lower cased string
String g=a.substring(0,2);//returns sub string of JAVA
String h=a.replace('J', 'j');//replaces the 'J' into 'j' at String a
System.out.println("a string is: "+a);
System.out.println("b string is: "+b);
System.out.println(" LENGTH OF STRING A IS: "+c);
System.out.println(" CONCAT OF A AND B IS: "+d);
System.out.println("CHAR AT 2ND POSITION IN B STTRING IS: "+e);
System.out.println(" LOWER CASED STRING OF A IS: "+f);
System.out.println("SUB STRING OF A IS: "+g);
System.out.println(" REPLACED STRING OF A IS: "+h);
}
}
OUTPUT:
~~~~~~~
a string is: JAVA
b string is: INTERPRETERS
LENGTH OF STRING A IS: 4
CONCAT OF A AND B IS: JAVAINTERPRETERS
CHAR AT 2ND POSITION IN B STTRING IS: T
LOWER CASED STRING OF A IS: java
SUB STRING OF A IS: JA
REPLACED STRING OF A IS: jAVA
for detailed description about functions please follow the link :CLICK HERE
~~~~~~~
Hello ,Now I like to share about the concept Strings. In JAVA we can perform the string operation using the class String(java.lang.String)w can perform the operations such as conversion the string from lowercase to uppercase and string concatenation, trimming etc using its default functions of String class.
//PROGRAM TO PERFORM STRING OPERATIONS
public class b
{
public static void main(String[] args)
{
String a="JAVA";//declaration of string
String b="INTERPRETERS";
int c=a.length();//TO FIND LENGTH OF GIVEN STRING JAVA USING "length function"
String d=a.concat(b);//here "JAVA" IS CONCAT WITH "INTERPRETERS"
char e=b.charAt(2);//returns the character at 2nd position of string
String f=a.toLowerCase();//converts the upper cased to lower cased string
String g=a.substring(0,2);//returns sub string of JAVA
String h=a.replace('J', 'j');//replaces the 'J' into 'j' at String a
System.out.println("a string is: "+a);
System.out.println("b string is: "+b);
System.out.println(" LENGTH OF STRING A IS: "+c);
System.out.println(" CONCAT OF A AND B IS: "+d);
System.out.println("CHAR AT 2ND POSITION IN B STTRING IS: "+e);
System.out.println(" LOWER CASED STRING OF A IS: "+f);
System.out.println("SUB STRING OF A IS: "+g);
System.out.println(" REPLACED STRING OF A IS: "+h);
}
}
OUTPUT:
~~~~~~~
a string is: JAVA
b string is: INTERPRETERS
LENGTH OF STRING A IS: 4
CONCAT OF A AND B IS: JAVAINTERPRETERS
CHAR AT 2ND POSITION IN B STTRING IS: T
LOWER CASED STRING OF A IS: java
SUB STRING OF A IS: JA
REPLACED STRING OF A IS: jAVA
for detailed description about functions please follow the link :CLICK HERE
No comments:
Post a Comment