HOW YOUR TEXTUAL CODE IS READ(2)
HOW YOUR TEXTUAL CODE IS READ(2):
(continued from 1)
COMMENTS:
There are two types of comments in the java programming language:
- The traditional comment, /* text */
- The end-of-line comment, // text
Note: a. that the text is ignored in both type of comments.
Also, b. Comments do not nest.
/* /* */ */ will give syntax error.
- If comments occur in other comments, the special meaning is lost.
/* // */ the EOL(//) comment will lose its special meaning.
package examples;
class CommentsExamples {
public static void main(String[] args) {
// Simple example: comments do not nest.
//Try writing the below and your compiler should give
//an error
/*/* */ */
//traditional comments have no special meaning in comments
//that are end-of-line, example:
// /* */
/*// */
}
}
IDENTIFIERS:
An identifier is an unlimited-length sequence of java letters or java digits, which letters or digits are in the Unicode character set. The beginning of an identifier must be a java letter.
The java digits are the ASCII digits 0-9(\u0030-\u0039).
// I want to use the letter below as an identifier
//beginning letter being french
char frenchletter = '\u00C7';
System.out.println("Valid. Can use "+frenchletter+" as start of identifier.");
}else {
System.out.println("Sorry, not first letter of identifier.");
}
char trademark = '\u0099';
System.out.println(Character.isJavaIdentifierPart(trademark));
//yes, true!
//To check for identifier sameness.
char bigs = '\u0053', smalls = '\u0073';
System.out.print("If the two s are the same identifiers");
System.out.println(" our compiler should return true.");
//now checking
if (bigs == smalls){
System.out.println("True");
}else {System.out.println("Sorry, big and small s are
different.");}
}
}
KEYWORDS:
The keywords in java are:
abstract
assert
boolean
break
case
catch
char
class
const
continue
for
new
switch
default
if
package
synchronized
double
implements
protected
throw
byte
else
import
public
throws
extends
int
short
transient
final
interface
static
try
finally
long
strictfp
void
enum
instanceof
return
volatile
float
native
super
while
const and goto are reserved in java for making a check on their appearance in code as against C++ code.
1 comment:
Good words.
Post a Comment