I have planned to learn DSA in JAVA language.
Hello Everyone, I will be starting my #140dayschallenge journey today.
Install Java and IDE's
- Install JDK (https://www.oracle.com/in/java/technologies/javase-downloads.html)
- Install IntelliJ (https://www.jetbrains.com/idea/download/#section=mac) OR
- Install Visual Studio Code (VS Code) - Prefer THIS (https://code.visualstudio.com/download)
A variable is a container (storage area) used to hold data. Each variable should be given a unique name (identifier).
-
Local Variable : A variable declared inside the body of the method is called local variable. A local variable cannot be defined with "static" keyword.
-
Instance Variable : A variable declared inside the class but outside the body of the method, is called an instance variable. It is not declared as static.
-
Static variable : A variable that is declared as static is called a static variable. It cannot be local.
- Java is case sensitive. Hence, age and AGE are two different variables.
- Variables must start with either a letter or an underscore,or a dollar, $ sign. They cannot start with a number.
- Variable names can't use whitespace.
- If you choose one-word variable names, use all lowercase letters.
Data types are declarations for variables. This determines the type and size of data associated with variables which is essential to know since different data types occupy different sizes of memory. Eg : String, Arrays
There are 2 types of Data Types :
- Primitive Data types : to store simple values
- Non-Primitive Data types : to store complex values
Primitive Data Types
- These are the data types of fixed size.
Non-Primitive Data Types
- These are of variable size & are usually declared with a ‘new’ keyword.
A constant is a variable in Java which has a fixed value i.e. it cannot be assigned a different value once assigned.
Operator in Java is a symbol that is used to perform operations.
Types of operators in Java which are given below :
- Unary Operator
- Arithmetic Operator
- Shift Operator
- Relational Operator
- Bitwise Operator
- Logical Operator
- Ternary Operator
- Assignment Operator
Java provides statements that can be used to control the flow of Java code. Such statements are called control flow statements.
Types of control flow statements :
- Decision Making statements
- if statements
- switch statement
- Loop statements
- do while loop
- while loop
- for loop
- for-each loop
- Jump statements
- break statement
- continue statement
Decision-Making statements : Decision-making statements evaluate the Boolean expression and control the program flow depending upon the result of the condition provided.
- If Statement: the "if" statement is used to evaluate a condition. The control of the program is diverted depending upon the specific condition.
- Simple if statement
- if-else statement
- if-else-if ladder
- Nested if-statement
If statements : The ‘If statement’ is a rule that is performed when the condition is satisfied or true.
Java if-else statement : The if-else condition is a set of rules or statements that perform a distinct set of conditions.
Java if-else-if Ladder : The if else ladder statement is a set of conditions which is based on “Nested if condition”. The if-else ladder condition performs the expressions from top to down.
Nested if-statement : It is also possible to use the if-else statements inside an if-else statement.