Showing posts with label string tutorial. Show all posts
Showing posts with label string tutorial. Show all posts

Tuesday, November 25, 2014

String Manipulation in java

In example, Test class has a main method and local string variable with few string manipulation i.e length of string, character at given position and string comparison.
 public class Test1  
 {  
      public static void main(String args[])  
      {  
           String result1="hello java";  
           int result2=result1.length()%3;  
           char result3=result1.charAt(3);  
           String result4="result1"+"result1";  
           System.out.println(result1.equals("hello java"));  
           System.out.println(result2);  
           System.out.println(result3);  
           System.out.println(result4);  
           System.out.println(result1.lastIndexOf('w'));  
      }  
 }