Showing posts with label String. Show all posts
Showing posts with label String. Show all posts

Thursday, 13 June 2013

getChars:  
getChars is used to select the more than one character using locations

// Program to use of getchars

class getChars
{
public static void main(String arr[])
{
String a="There is Shaminder singh";
int start=6;
int end=14;
char buf[]= new char[end-start];
a.getChars(start,end,buf,0);
System.out.println(buf);
}
}




Use of getChars

getChars:  
getChars is used to select the more than one character using locations

// Program to use of getchars

class getChars
{
public static void main(String arr[])
{
String a="There is Shaminder singh";
int start=6;
int end=14;
char buf[]= new char[end-start];
a.getChars(start,end,buf,0);
System.out.println(buf);
}
}




LENGTH():   length() is used to find the length of a string


// To print the string and its length.

class Length
{
public static void main(String arr[])
{
String s="getcoderesults.com";                   //For declare String literals
System.out.println(s);
System.out.println(s.length());

}}



Output:



Length Function

LENGTH():   length() is used to find the length of a string


// To print the string and its length.

class Length
{
public static void main(String arr[])
{
String s="getcoderesults.com";                   //For declare String literals
System.out.println(s);
System.out.println(s.length());

}}



Output:



This entry was posted in :
// To find the character on a given location

class ExactLoc
{
public static void main(String arr[])
{
String a="shaminder";
System.out.println(a.charAt(4));
}}






Use of charAt

// To find the character on a given location

class ExactLoc
{
public static void main(String arr[])
{
String a="shaminder";
System.out.println(a.charAt(4));
}}






This entry was posted in :
// A simple program to print the length of character.

class A
{
public static void main(String arr[])
{
char ch[]={'a', 'b', 'c', 'd', 'e'};
String s1=new String(ch);
System.out.println(s1.length());
}
}



Output:

Use of Lenth Function

// A simple program to print the length of character.

class A
{
public static void main(String arr[])
{
char ch[]={'a', 'b', 'c', 'd', 'e'};
String s1=new String(ch);
System.out.println(s1.length());
}
}



Output:
This entry was posted in :

Tuesday, 11 June 2013

String Handling provides a lot of concepts that can be performed on a string such as concatinating string, comparing string, substring etc. 

// Simple program to  print the length of character in a array

  class A
{
public static void main(String arr[])
{
char ch[]={'a', 'b', 'c', 'd', 'e'};
String s1=new String(ch);
System.out.println(s1.length());
}
}


Output:





























String Handling provides a lot of concepts that can be performed on a string such as concatinating string, comparing string, substring etc. 

// Simple program to  print the length of character in a array

  class A
{
public static void main(String arr[])
{
char ch[]={'a', 'b', 'c', 'd', 'e'};
String s1=new String(ch);
System.out.println(s1.length());
}
}


Output:





























This entry was posted in :