Java is a very versatile language. It is the language of future on the programming perspective. In this tutorial hub I will be providing you with Java fundamentals. If we talk about Java fundamentals we basically deal with the syntax and semantics of the language. Some of the fundamentals of language are been described below :
- Whitespace
- Styles
// Bad Style Coding // Very hard to read, no indents used public class Welcome { public static void main(String[] args){ int i = 0; // single line comment for(int i=0;i<=10;i++){ int j = 1; int k = j; System.out.println("Welcome to comments"); } }
// Good Style Coding // Very easy to read, excellent use of indents public class Welcome { public static void main(String[] args){ int i = 0; // single line comment for(int i=0;i<=10;i++){ int j = 1; int k = j; System.out.println("Welcome to comments"); } } }
- Comments
public class Welcome { public static void main(String[] args){ int i = 0; // single line comment for(int i=0;i<=10;i++){ /* int j = 1; int k = j; System.out.println("Welcome to comments"); */ /* multi-line comment, whole code between is commented out */ } } }
- Identifiers
Identifiers are names given to variables , class , methods in a Java source code. There are rules imposed on the naming conventions of Java identifiers. The rules are as follows:
- An Identifier must begin with a unicode character, dollar sign or underscore.
- After the first character you can add numbers along with unicode characters, dollar sign and underscore.
- Generally use of currency symbols such as dollar sign should be avoided.
- Java identifiers are Case-sensitive.
- Java identifiers should not be a reserved keyword of Java.
- Capital letters should be used to separate two words.
- Reserved Keywords
- Separators
- Literals
- Escape Sequences
Escape Sequences in Java video :-