Showing posts with label JAVA Character Class. Show all posts
Showing posts with label JAVA Character Class. Show all posts

Saturday, 24 August 2013

Java - toUpperCase() Method

Description:

The method returns the uppercase form of the specified char value.

Syntax:

char toUpperCase(char ch)

Parameters:

Here is the detail of parameters:
  • ch -- Primitive character type

Return Value :

  • This method Returns the uppercase form of the specified char value.

Example:

public class Test{

   public static void main(String args[]){
      System.out.println(Character.toUpperCase('c'));
      System.out.println(Character.toUpperCase('C'));
   }
}
This produces following result:
C
C

Java - toString() Method

Description:

The method returns a String object representing the specified character valuethat is, a one-character string.

Syntax:

String toString(char ch)

Parameters:

Here is the detail of parameters:
  • ch -- Primitive character type

Return Value:

  • This method Returns String object

Example:

public class Test{

   public static void main(String args[]){
      System.out.println(Character.toString('c'));
      System.out.println(Character.toString('C'));
   }
}
This produces following result:
c
C

Java - toLowerCase() Method

Description:

The method returns the lowercase form of the specified char value.

Syntax:

char toLowerCase(char ch)

Parameters:

Here is the detail of parameters:
  • ch -- Primitive character type

Return Value:

  • This method Returns the lowercase form of the specified char value.

Example:

public class Test{

   public static void main(String args[]){
      System.out.println(Character.toLowerCase('c'));
      System.out.println(Character.toLowerCase('C'));
   }
}
This produces following result:
c
c

Java - isWhitespace() Method

Description:

The method determines whether the specified char value is a white space which includes space, tab or new line.

Syntax:

boolean isWhitespace(char ch)

Parameters:

Here is the detail of parameters:
  • ch -- Primitive character type

Return Value:

  • This method Returns true if passed character is really a white space.

Example:

public class Test{

   public static void main(String args[]){
      System.out.println(Character.isWhitespace('c'));
      System.out.println(Character.isWhitespace(' '));
      System.out.println(Character.isWhitespace('\n'));
      System.out.println(Character.isWhitespace('\t'));
   }
}
This produces following result:
false
true
true
true

Java - isUpperCase() Method

Description:

The method determines whether the specified char value is uppercase.

Syntax:

boolean isUpperCase(char ch)

Parameters:

Here is the detail of parameters:
  • ch -- Primitive character type

Return Value:

  • This method Returns true if passed character is really an uppercase.

Example:

public class Test{

   public static void main(String args[]){
      System.out.println( Character.isUpperCase('c'));
      System.out.println( Character.isUpperCase('C'));
      System.out.println( Character.isUpperCase('\n'));
      System.out.println( Character.isUpperCase('\t'));
   }
}
This produces following result:
false
true
false
false

Java - isLowerCase() Method

Description:

The method determines whether the specified char value is lowercase.

Syntax:

boolean isLowerCase(char ch)

Parameters:

Here is the detail of parameters:
  • ch -- Primitive character type

Return Value:

  • This method Returns true if passed character is really an lowercase.

Example:

public class Test{

   public static void main(String args[]){
      System.out.println(Character.isLowerCase('c'));
      System.out.println(Character.isLowerCase('C'));
      System.out.println(Character.isLowerCase('\n'));
      System.out.println(Character.isLowerCase('\t'));
   }
}
This produces following result:
true
false
false
false

Java - isLetter() Method

Description:

The method determines whether the specified char value is a letter.

Syntax:

boolean isLetter(char ch)

Parameters:

Here is the detail of parameters:
  • ch -- Primitive character type

Return Value:

  • This method Returns true if passed character is really a character.

Example:

public class Test {

   public static void main(String args[]) {
      System.out.println(Character.isLetter('c'));
      System.out.println(Character.isLetter('5'));
   }
}
This produces following result:
true
false

Java - isDigit() Method

Description:

The method determines whether the specified char value is a digit.

Syntax:

boolean isDigit(char ch)

Parameters:

Here is the detail of parameters:
  • ch -- Primitive character type

Return Value:

  • This method Returns true if passed character is really a digit.

Example:

public class Test {

   public static void main(String args[]) {
      System.out.println(Character.isDigit('c'));
      System.out.println(Character.isDigit('5'));
   }
}
This produces following result:
false
true