Determines whether a character can be a start character or a subsequent character of a Java identifier.

Source: Internet
Author: User

* (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 ");
}

}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.