Posted by: Sourav | August 7, 2012

String functions in Java


public class Stringfunctions{
    
    
    public static void main(String[] args){
        
        
      //  System.out.println(“Hello!!!!!!!!!!!!!!!!!!!!”);
      String name1=”sourav”;
      String name2=”sourav”;
      
      if(name1.equals(name2)){
        System.out.println(“They are same”);
        
        
      }
      String sentence=”The quick brown fox jumped over the lazy dog”;
      //String[] data=sentence.split(” “);
      //System.out.println(data[8]);
      
     // String[] data=sentence.split(” “,3);
      
       //     System.out.println(data[1]);
       String sentence2=”     The quick brown fox jumped over the lazy dog    “;
       
       String sentence3=sentence2.trim();
          System.out.println(sentence2);
       System.out.println(sentence3);
    }
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: