CLASSPATH
Java uses the environment variable CLASSPATH to locate class libraries
• .class files those needed to compile or run the program it searches from
CLASSPATH
• By default class path consists only the current directory but you can provide them in –classpath option of javac or include directories in CLASSPATH environment variables.
• Example classpath = . ; c:\java\lib; c:\csi211\lab
Some Basic Java Syntax
Java Comments
/* Standard C comment works */
// C++ comment works
/** Special comment for documentation – java comments */
class Syntax
{ public static void main( String args[] ){
int aVariable = 5;double aFloat = 5.8;
if ( aVariable < aFloat )System.out.println( "True" );
int b = 10; // This is legal in Javachar c;c = 'a';
}}
Java Program Style and Layout
• Three different indentation styles you can use
• You can pick a reasonable indentation style and use it consistently in your programs
Style#1
class Syntax { // brace starts from here
public static void main( String args[] ) {int aVariable = 5;if ( aVariable < aFloat )
System.out.println( "True" );}}
Style #2
class Syntax
{ // brace startspublic static void main( String args[] ){
int aVariable = 5;if ( aVariable < aFloat )System.out.println( "True" );}}
Style#3
class Syntax{// brace startspublic static void main( String args[] )
{int aVariable = 5;if ( aVariable < aFloat )
System.out.println( "True" );}}
Naming conventions
Class Naming Uses Capitalized word(s) i.e. Title case
Examples:- HelloWorld, MyList, StudentMark
Wrong: helloWorld, HW (do not use abbreviat
Java uses the environment variable CLASSPATH to locate class libraries
• .class files those needed to compile or run the program it searches from
CLASSPATH
• By default class path consists only the current directory but you can provide them in –classpath option of javac or include directories in CLASSPATH environment variables.
• Example classpath = . ; c:\java\lib; c:\csi211\lab
Some Basic Java Syntax
Java Comments
/* Standard C comment works */
// C++ comment works
/** Special comment for documentation – java comments */
class Syntax
{ public static void main( String args[] ){
int aVariable = 5;double aFloat = 5.8;
if ( aVariable < aFloat )System.out.println( "True" );
int b = 10; // This is legal in Javachar c;c = 'a';
}}
Java Program Style and Layout
• Three different indentation styles you can use
• You can pick a reasonable indentation style and use it consistently in your programs
Style#1
class Syntax { // brace starts from here
public static void main( String args[] ) {int aVariable = 5;if ( aVariable < aFloat )
System.out.println( "True" );}}
Style #2
class Syntax
{ // brace startspublic static void main( String args[] ){
int aVariable = 5;if ( aVariable < aFloat )System.out.println( "True" );}}
Style#3
class Syntax{// brace startspublic static void main( String args[] )
{int aVariable = 5;if ( aVariable < aFloat )
System.out.println( "True" );}}
Naming conventions
Class Naming Uses Capitalized word(s) i.e. Title case
Examples:- HelloWorld, MyList, StudentMark
Wrong: helloWorld, HW (do not use abbreviat
No comments:
Post a Comment