Friday, 14 June 2013

String operations

So there are various Functions that we could perform on string so just keep looking at the examples given
Discription will be given along with
To begin with--

1- how to declare  a string and various ways
this just prints java on the screen
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
import java.lang.*;
import java.io.*;
class f
{
public static void main(String arg[]){
char a[]={'j','a','v','a'};

String s1=new String(a);
String s2=new String(s1);
System.out.println(""+s1);
System.out.println(""+s2);
}}

]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]

2-We can also combine different strings as follows
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
import java.lang.*;
import java.io.*;
class f
{
public static void main(String arg[]){
char a[]={'j','a','v','a'};

String s1=new String(a);
String s2=new String(s1);
System.out.println(""+s1);
System.out.println(""+s2);
String s3=new String(s2+s1);
System.out.println(s3);
}}
]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
3- Lets see something more for example if we want only jav to be printed or av or va then see below
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
import java.lang.*;
import java.io.*;
class f
{
public static void main(String arg[]){
char a[]={'j','a','v','a'};

String s1=new String(a);
String s2=new String(s1);
String s4=new String(a,0,3);//(prints characters form 0-3)
System.out.println(""+s1);
System.out.println(""+s2);
String s3=new String(s2+s1);
System.out.println(s3);
System.out.println(s4);//output=jav
}}
]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
THATS ALL FOR NOW BUT CHECK MY NEXT POSTS FOR MORE AND LET ME KNOW IF THERE IS ANY PROBLEM

No comments:

Post a Comment