Skip to content

Bethegnt/140-Days-Challenge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

94 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

140dayschallenges

I have planned to learn DSA in JAVA language.

Screenshot 2022-10-06 at 12 26 22 AM

Day-01

Hello Everyone, I will be starting my #140dayschallenge journey today.

Java - Introduction to Programming

Installation Setup

Install Java and IDE's

First Program in java

First Program

Variables & Data Types

Variables

A variable is a container (storage area) used to hold data. Each variable should be given a unique name (identifier).

Types of Variable :

  1. Local Variable : A variable declared inside the body of the method is called local variable. A local variable cannot be defined with "static" keyword.

  2. 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.

  3. Static variable : A variable that is declared as static is called a static variable. It cannot be local.

Variables

Rules for naming a variable

  1. Java is case sensitive. Hence, age and AGE are two different variables.
  2. Variables must start with either a letter or an underscore,or a dollar, $ sign. They cannot start with a number.
  3. Variable names can't use whitespace.
  4. If you choose one-word variable names, use all lowercase letters.

Data Types

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.

Data Types in Java

Screenshot 2022-10-06 at 1 48 24 AM

Data Types

Constants

A constant is a variable in Java which has a fixed value i.e. it cannot be assigned a different value once assigned.

Operators

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

Screenshot 2022-10-06 at 5 11 56 PM

Unary Operators

Arithmetic Operators

Left Shift Operators

Right Shift Operators

Relational Operators

Logical  vs Bitwise Operators

Ternary Operators

Assignment Operators

Java Control Flow

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.

  1. 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.

Syntax of if Statement

Simple If Statement

Java if-else statement : The if-else condition is a set of rules or statements that perform a distinct set of conditions.

Syntax of if-else Statement

Simple If-else Statement

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.

Syntax Java if-else-if Ladder Statement

 if-else-if ladder Statement

Nested if-statement : It is also possible to use the if-else statements inside an if-else statement.

Syntax Java Nested-if Statement

Nested-if Statement

Releases

No releases published

Packages

No packages published

Languages