* (Program header annotation starts)
* Copyright and version Declaration of the program
* Copyright (c) 2011, a student from the computer College of Yantai University
* All rights reserved.
* File name: determines whether a character can be the start or subsequent character of a Java identifier.
* Author: Lei hengxin
* Completion date: January 1, August 4, 2012
* Version No.: V1.0
* Description of tasks and Solutions
* Input description:
* Problem description:
* Program output:
* End the comment in the program Header
*/
[Java]
//////////////////////////////////////// /////////////////////////////////////
//
// M_Identifier.java
//
// Developer: Lei hengxin
//////////////////////////////////////// /////////////////////////////////////
// Introduction:
// A routine used to determine whether a character can be used as the start character of a Java identifier or a subsequent character
//////////////////////////////////////// ////////////////////////////////////
Public class M_Identifier {
Public static void main (String args [])
{
Char c = 'modem ';
If (Character. isJavaIdentifierStart (c ))
{
System. out. println ("character \ '" + c + "\' can be the first character of an identifier"); // This is a java class. lang. the static member method of Character. It is used to determine whether a given Character ch can be the start Character of a Java identifier.
}
Else
{
System. out. println ("character \ '" + c + "\' cannot be the first character of an identifier"); // Note: method System. out. println automatically breaks the line after the output string. Method System. out. print does not wrap a line after the output string.
}
If (Character. isJavaIdentifierStart (c ))
{
System. out. println ("character \ '" + c + "\' can be used as an identifier except for the first character"); // This is a java class. lang. the static member method of Character. It is used to determine whether a given Character ch can be followed by a Java identifier.
}
Else
{
System. out. println ("character \ '" + c + "\' cannot be an identifier except the first character ");
}
}
}
Running result:
Note: If you change the method System. out. println to the method System. out. print.
[Java]
//////////////////////////////////////// /////////////////////////////////////
//
// M_Identifier.java
// Www.dgbalance.com
// Developer: Lei hengxin
//////////////////////////////////////// /////////////////////////////////////
// Introduction:
// A routine used to determine whether a character can be used as the start character of a Java identifier or a subsequent character
//////////////////////////////////////// ////////////////////////////////////
Public class M_Identifier {
Public static void main (String args [])
{
Char c = 'modem ';
If (Character. isJavaIdentifierStart (c ))
{
<Span style = "color: # ff0000;"> System. out. print </span> ("character \ '" + c + "\' can be the first character of an identifier"); // This is a java class. lang. the static member method of Character. It is used to determine whether a given Character ch can be the start Character of a Java identifier.
}
Else
{
<Span style = "color: # ff0000;"> System. out. print </span> ("character \ '" + c + "\' cannot be the first character of an identifier"); // Note: The method is System. out. println automatically breaks the line after the output string. Method System. out. print does not wrap a line after the output string.
}
If (Character. isJavaIdentifierStart (c ))
{
<Span style = "color: # ff0000;"> System. out. print </span> ("character \ '" + c + "\' can be an identifier except the first character"); // This is a java-like. lang. the static member method of Character. It is used to determine whether a given Character ch can be followed by a Java identifier.
}
Else
{
<Span style = "color: # ff0000;"> System. out. print </span> ("character \ '" + c + "\' cannot be an identifier except the first character ");
}
}
}