Wednesday, 25 April 2018

Core Java: Java Modifiers and White Space

Like other languages, it is possible to modify classes, methods, etc., by using modifiers. There are two categories of modifiers:
·        Access Modifiers: default, public, protected, private
·        Non-access Modifiers: final, abstract, strictfp

White Spaces:
 Blank, tab and newline are collectively called white spaces.
Ø    Java, like most of the computing languages, ignores extra white spaces. That is, multiple contiguous white spaces are treated as a single white space.
You need to use a white space to separate two keywords or tokens to avoid ambiguity, e.g.,
int sum=0;   // Cannot write intsum=0. Need at least one white space between "int" and "sum"
double average;  // Again, need at least a white space between "double" and "average"
Additional white spaces and extra lines are, however, ignored, e.g.,
// same as above
int  sum  =  0      ;
double  average  ;

No comments:

Post a Comment

Please write your view and suggestion....