Friday, 14 June 2013

string operations

1-if you want the string you have entered or user enters should come in upper or lower case do as follows
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
import java.io.*;
class dp
{
public static void main(String arg[])
{
String a="welcome TO java";
System.out.println(a.toLowerCase());
System.out.println(a.toUpperCase());
}
}
]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
2-if you want to check whether the value of string entered by user is equals to entered by you
Basically you are compairing two strings whether they are equal or not then do as follows
it could be done in two ways
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[

class dro{
public static void main(String arg[])
{
String a=("what");
String b=("WHAT");
boolean c;
System.out.println(a.equals(b)); //checks for capitals and small letters
System.out.println(a.equalsIgnoreCase(b));// ignores capitals and small letters only compare words
}

}
]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
3-some really easy functions that you could just do by looking at them look below
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
class combine{
public static void main(String arg[]){
String a= "this is combination of all";
System.out.println(a.lastIndexOf ('l'));//prints the value of  last position of  l in this case is 26
System.out.println(a.lastIndexOf ('l'));//prints the value of  first position of l
}}
]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
4-if you want to trim one of the blank spaces from front of string
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
class combine{
public static void main(String arg[]){
String g=" what";
System.out.println(g.trim());//trims the space in front

}}
]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]

No comments:

Post a Comment