/* RULE: identofiers are case sensitive ( balance and Balance are two different) */ |
class CaseSencitive { public static void main(String[] args) { int bal; int Bal; System.out.println("legal identifiers"); } } |
Friday, April 1, 2011
CaseSencitive
Illegel
/*
RULE: following are some illegel identifiers
*/
class Illegel
{
public static void main(String[] args)
{
int 7g;
int .j;
int -m;
int :b;
int s#;
int int;
int for;
int enum;
System.out.println("illegal identifiers");
}
}
RULE: following are some illegel identifiers
*/
class Illegel
{
public static void main(String[] args)
{
int 7g;
int .j;
int -m;
int :b;
int s#;
int int;
int for;
int enum;
System.out.println("illegal identifiers");
}
}
DontUse
/*
RULE: dont use keywords as identifiers
*/
class DontUse
{
public static void main(String[] args)
{
int if;
int for;
System.out.println(" illegal start of expressition");
}
}
RULE: dont use keywords as identifiers
*/
class DontUse
{
public static void main(String[] args)
{
int if;
int for;
System.out.println(" illegal start of expressition");
}
}
NoLimit
/*
RULE: there is no limit to the number of characters in the identifiers
*/
class NoLimit
{
public static void main(String[] args)
{
int asdf_hghighiggu_jhgjhghgu_kjghuge_njgh$jfhfghaf;
System.out.println("No Limit ");
}
}
RULE: there is no limit to the number of characters in the identifiers
*/
class NoLimit
{
public static void main(String[] args)
{
int asdf_hghighiggu_jhgjhghgu_kjghuge_njgh$jfhfghaf;
System.out.println("No Limit ");
}
}
After the first character
/*
RULE: After the first character ( $ or _ or character ) identifiers contains
any thing i.e numbers also
*/
class AfterFirst
{
public static void main(String[] args)
{
int a333424;
int _34we;
int $a23deu;
System.out.println("legal identifiers");
}
}
RULE: After the first character ( $ or _ or character ) identifiers contains
any thing i.e numbers also
*/
class AfterFirst
{
public static void main(String[] args)
{
int a333424;
int _34we;
int $a23deu;
System.out.println("legal identifiers");
}
}
identifyrs starts with characters
/*
RULE: identifyrs starts with characters(a to z or A to Z)
or starts with underscore (_) and currency ($)
not starts with numbers
*/
class StartWith
{
public static void main(String[] args)
{
int $x;
int _a;
int m;
System.out.println("legal identifiers");
}
}
RULE: identifyrs starts with characters(a to z or A to Z)
or starts with underscore (_) and currency ($)
not starts with numbers
*/
class StartWith
{
public static void main(String[] args)
{
int $x;
int _a;
int m;
System.out.println("legal identifiers");
}
}
Labels:
c
classes and interfaces
/*
RULE: classes and interfaces
the first letter of the word should be Capital and connectig word letter also capital
the name should be nouns
*/
class Dog
{
public static void main(String[] args)
{
System.out.println("Hello Dog!");
}
}
class PrintWriter
{
System.out.println("this is class");
}
interface Car
{
}
interface Runnable
{
}
RULE: classes and interfaces
the first letter of the word should be Capital and connectig word letter also capital
the name should be nouns
*/
class Dog
{
public static void main(String[] args)
{
System.out.println("Hello Dog!");
}
}
class PrintWriter
{
System.out.println("this is class");
}
interface Car
{
}
interface Runnable
{
}
Methods
/*
RULE: The first letter should be small letter and followed
words shold be capital letters
*/
class Methods
{
int getBalance(int accno)
{
System.out.prinln("balance is")
}
void setBalance(int acc,int amount)
{
}
public static void main(String[] args)
{
System.out.println("Hello World!");
}
}
RULE: The first letter should be small letter and followed
words shold be capital letters
*/
class Methods
{
int getBalance(int accno)
{
System.out.prinln("balance is")
}
void setBalance(int acc,int amount)
{
}
public static void main(String[] args)
{
System.out.println("Hello World!");
}
}
Variables
/*
RULE: like methods rules
starting letter should be small then next word with capital letter
SUN recomended that it should be small ans good meaning full sound
*/
class Variables
{
public static void main(String[] args)
{
int buttonWidth;
int bal;
double accountNo;
System.out.println("legel convetions");
}
}
RULE: like methods rules
starting letter should be small then next word with capital letter
SUN recomended that it should be small ans good meaning full sound
*/
class Variables
{
public static void main(String[] args)
{
int buttonWidth;
int bal;
double accountNo;
System.out.println("legel convetions");
}
}
Constants
/*
RULE: constants are should be capital letters
they are used final and static keywords
*/
class Constants
{
static final double accountNumber=22323543;
public static void main(String[] args)
{
final float PI=22.7f;
System.out.println("legel constant code convention");
}
}
RULE: constants are should be capital letters
they are used final and static keywords
*/
class Constants
{
static final double accountNumber=22323543;
public static void main(String[] args)
{
final float PI=22.7f;
System.out.println("legel constant code convention");
}
}
Subscribe to:
Posts (Atom)