Showing posts with label letter. Show all posts
Showing posts with label letter. Show all posts
Determine character is letter or digit
Complete source code below will show you, how to determine character is letter or digit in java.
*****************************************************************
COMPLETE SOURCE CODE FOR : DetermineCharacterIsLetterOrDigit.java
*****************************************************************
*****************************************************************
JUST COMPILE AND EXECUTE IT
*****************************************************************
*****************************************************************
COMPLETE SOURCE CODE FOR : DetermineCharacterIsLetterOrDigit.java
*****************************************************************
public class DetermineCharacterIsLetterOrDigit
{
public static void main(String[]args)
{
//Create a character using char with value(3)
//You can try change it's value to letter(k)
char a='3';
//Determine created character is letter or digit
//using method isLetterOrDigit from class Character.
//isLetterOrDigit is a static method, so we don't need to create object when
//we want to use it.
if(Character.isLetterOrDigit(a))
{
//Print (It is a letter or a digit) if character is a letter or digit
System.out.println("It is a letter or a digit");
}
else
{
//Print (It is not a letter or digit) if character is not a letter or digit
System.out.println("It is not a letter or digit");
}
}
}
*****************************************************************
JUST COMPILE AND EXECUTE IT
*****************************************************************
Determine character is letter or not
Complete source code below will show you, how to determine character is letter or not in java.
************************************************************
COMPLETE SOURCE CODE FOR : DetermineCharacterIsLetter.java
************************************************************
************************************************************
JUST COMPILE AND EXECUTE IT
************************************************************
************************************************************
COMPLETE SOURCE CODE FOR : DetermineCharacterIsLetter.java
************************************************************
public class DetermineCharacterIsLetter
{
public static void main(String[]args)
{
//Create a character using char with value(m)
char a='m';
//Determine created character is letter or not
//using method isLetter from class Character.
//isLetter is a static method, so we don't need to create object when
//we want to use it.
if(Character.isLetter(a))
{
//Print (It is a letter) if character is a letter
System.out.println("It is a letter");
}
else
{
//Print (It is not a letter) if character is not a letter
System.out.println("It is not a letter");
}
}
}
************************************************************
JUST COMPILE AND EXECUTE IT
************************************************************
Compare String ignore capital or ordinary letters
Complete source code below will show you, how to compare two string with same characteristic but ignore about capital or ordinary letters. The characteristic that i mean here is, number of characters and sequence of characters. We will use method equalsIgnoreCase().
****************************************************************************
COMPLETE SOURCE CODE FOR : CompareStringIgnoreCapitalOrOrdinaryLetters.java
****************************************************************************
****************************************************************************
JUST COMPILE AND EXECUTE IT
****************************************************************************
****************************************************************************
COMPLETE SOURCE CODE FOR : CompareStringIgnoreCapitalOrOrdinaryLetters.java
****************************************************************************
public class CompareStringIgnoreCapitalOrOrdinaryLetters
{
public static void main(String[]args)
{
//Create first String = aaAAA
//You can try other string that you want by change aaAAA
String firstString="aaAAA";
//Create second String = AAaaa
//You can try other string that you want by change AAaaa
String secondString="AAaaa";
//Check if first String is same or not to second String
if(firstString.equalsIgnoreCase(secondString))
{
//If first String equal to second String, it will print ( firstString is same to secondString )
System.out.println("firstString is same to secondString");
}
else
{
//If first String not equal to second String, it will print ( firstString is not same to secondString )
System.out.println("firstString is not same to secondString");
}
}
}
****************************************************************************
JUST COMPILE AND EXECUTE IT
****************************************************************************
Subscribe to:
Posts (Atom)