|
|
Submitted by KishorM on Sun, 08/29/2010 - 14:56
/*
* Convert upper case char to lower case char example.
*/
public class UpperCharToLowerChar {
public static void main(String args[]){
char upperCaseCh = 'A';
/*
* to convert upper case char to lower case use static toLowerCase method
* of Character class.
*/
char lowerCaseCh = Character.toLowerCase(upperCaseCh);
|
|
|
Submitted by KishorM on Sun, 08/29/2010 - 14:54
/*
* Convert lower case char to upper case char example.
*/
public class LowerCharToUpperChar {
public static void main(String args[]){
char lowerCaseCh = 'd';
/*
* to convert lower case char to upper case use static toUpperCase method
* of Character class.
*/
char upperCaseCh = Character.toUpperCase(lowerCaseCh);
|
|
|
Submitted by Megha on Sun, 08/29/2010 - 14:53
/*
* Convert String to char array example. Program to convert String object
* to array of character.
*/
public class StringToCharArray {
public static void main(String args[]){
String str = "Hello world";
//to convert string to char array, use toCharArray method of String
char[] ch = str.toCharArray();
|
|
|
Submitted by Megha on Sun, 08/29/2010 - 14:51
/*
* Convert String to char example. Program to convert String
* to char.
*/
public class StringToChar {
public static void main(String args[]){
String strCh = "h";
//to convert String to char use charAt method of String class.
char ch = strCh.charAt(0);
System.out.println("String converted to char: " + ch);
}
}
|
|
|
Submitted by Megha on Sun, 08/29/2010 - 14:50
/*
* Convert char to String example. Program to convert char
* to String.
*/
public class CharToString {
public static void main(String args[]){
char ch = 'e';
//to convert char to String use static toString method of Character class.
String strCh = Character.toString(ch);
System.out.println("char converted to String: " + strCh);
|
|
|
Submitted by Ramasubramaniam on Sun, 08/29/2010 - 14:37
/*
* Convert char to Integer example. Program to convert char
* to Integer wrapper number.
*/
public class CharToInteger {
public static void main(String args[]){
char ch = 'a';
//user Integer constructor
Integer iObj = new Integer((int)ch);
System.out.println("char converted to Integer: " + iObj);
}
}
|
|
|
Submitted by Ramasubramaniam on Sun, 08/29/2010 - 14:35
/*
* Convert char to int ASCII example. Program to convert char
* to int ASCII number.
*/
public class CharToInt {
public static void main(String args[]){
char ch = 'a';
//cast the character to convert it to int
int asciiCode = (int)ch;
System.out.println("char converted to int ascii code: " + asciiCode);
}
}
|
|