JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training 01 IntroductionTo Java 02 JVM vs JRE vs JDK 03 Java Fundamentals 04 Objects & Classes 05 Methods & Access Modifiers 06 Flow Of Control 07 Arrays Topics For Today’s Discussion
Introduction to JAva
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training Introduction To Java High Level Programming Language Father of Java is James Gosling Released by Sun Microsystems in 1996 Write Once Run Anywhere (WORA) Originally called OAK Free and Open Source Software
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training Features Of Java PortableRobustEasy Distributed Object Oriented Platform Independent MultithreadedInterpretedSecure
JVM vs JRE vs JDK
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training ✓ JVM is an abstract machine that doesn’t exist physically ✓ Provides runtime environment to drive the Java Code or applications ✓ It compiles the Java code into bytecode ✓ It is platform dependent JVM vs JRE vs JDK Java Virtual Machine JVM
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training ✓ JRE is the environment within which the JVM runs ✓ It contains a set of libraries + other files that JVM uses at runtime ✓ Also called Java RTE JRE JVM vs JRE vs JDK JVM Java Runtime Environment
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training JDK JRE JVM vs JRE vs JDK JVM ✓ JDK is a software development environment which is used to develop Java applications and applets ✓ It contains Development Tools and JRE Java Development Kit
Objects & Classes
& Classes
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training Java Objects An real-world entity that has state and behaviour is known as an object 01State It is the data (value) of an object Behavior02 It is the functionality) of an object 03 Identity The object identity is typically implemented via a unique ID that is used internally by the JVM CHARACTERISTICS
& Classes
Objects &
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training Java Classes A class is a group of objects which have common properties class <class_name>{ field; method; }
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training Java Classes A class may contain Fields Methods Constructors Blocks Nested Class & Interface class <class_name>{ field; method; }
Java Fundamentals Variables DataTypes Operators
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training Variables DataTypes Operators Variable refers to the name of reserved memory area 1 2 3 Instance Variables Static Variables Local Variables Java Fundamentals - Variables
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training Variables DataTypes Operators DataTypes Primitive Non-Primitive Boolean Numeric Character Integral Integer FloatingPoint boolean char byte short int long float double StringArray Java Fundamentals – Data Types
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training Variables DataTypes Operators 2 31 4 5 6 7 Arithmetic Operators Bitwise Operators Logical Operators Relational Operators Ternary Operators Assignment Operators 8 + - * ? % ^ & | && || < > <= >= == != ? : = += -= *= /= %= &= ^= |= <<= >>= >>>= ++X --X X++ X-- +X –X ! ~ << >> >>> Shift Operators Unary Operators Java Fundamentals - Operators
Java Methods
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training Java Methods A method is a set of code that is grouped together to perform a specific operation Pre Defined or Standard Library Methods User Defined Methods A method must be written inside a class Each method has its own signature Java provides two types of methods
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training Java User Defined Methods Method Initialization Method Invocation To use a method, you need to perform two steps:
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training Java Methods Method Initialization Method Invocation modifier returnType nameOfMethod (Parameter List) { // method body } ✓ A method can be parameterized or non-parameterized ✓ Method definition consists of a method header and a method body ✓ You can Overload Method i.e. Provide same name to more than one method but their data type or parameter list must be different
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training Java Methods Method Initialization Method Invocation ✓ To use a method it needs to be invoked or called ✓ A method can be called in two ways: 1. Call by Value 2. Call by Reference ✓ When a program invokes a method, the program control gets transferred to the called method methodName() methodName(parameter1, parameter2...)
Access Modifiers
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training Access Modifiers Access modifiers helps to restrict the scope of a class, constructor , variable , method or data member Default Public Private Protected
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training Access Modifiers Default Public Private Protected Same class Same Package subclass Same Package non- subclass Different package subclass Different package non- subclass Yes Yes Yes Yes Yes No Yes Yes Yes No Yes Yes No No Yes Yes No No No Yes
My First Java Program
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training My First Java Program class Demo{ public static void main(String args[]){ System.out.println("Hello Edureka!!!"); } } public static void main(String args[])
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training public static void main String args[] My First Java Program public static void main(String args[])
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training public static void main(String args[]) It is a keyword which identifies the class related thing It is used to define the Return Type of the Method It is the name of the method that is searched by JVM as a starting point for an application with a particular signature only It is the parameter to the main Method where the argument name could be anything It is the access modifier of the main method My First Java Program public static void main String args[] NOTE: main() in Java is the most important method as it is the entry point of any java program
For While DoWhile Iterative Statements
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training For While DoWhile It is a control structure that allows us to repeat certain operations by incrementing and evaluating a loop counter Iterative Statements – For Loop Statement Initialization Condition Increment /Decrement False True START END
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training For While DoWhile Iterative Statements – For Loop Syntax for(initialization; condition; incr/dcr) { code block; } Statement Initialization Condition Increment /Decrement False True START END
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training For While DoWhile Iterative Statements – While Loop It is a control structure that allows us to specify that a certain statement is to be executed repetitively until the loop condition is false Statement Condition False True START END
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training For While DoWhile Iterative Statements – While Loop Syntax while (boolean condition) { loop statements... } Statement Condition False True START END
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training For While DoWhile Iterative Statements – Do While Loop It is a control structure that allows code to be executed repeatedly based on a given Boolean condition and tests the condition before executing the loop body Statement Condition False True START END
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training For While DoWhile Iterative Statements – Do While Loop Statement Condition False True START END Syntax do{ //code to be executed } while(condition);
Conditional Statements If If-Else Switch
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training If If-Else Switch Conditional Statements - If It is the simplest selection statement in the Java language that checks the condition and executes the loop if condition is true If Nested If
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training If If-Else Switch Conditional Statements - If If is the most simple decision making statement that decides whether a certain statement or block of statements will be executed or not Body of If True False START END Test Expression Statement below If If Nested If
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training If If-Else Switch Conditional Statements - If Syntax if(condition) { //Statements to execute if condition is true } If Nested If
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training If If-Else Switch Conditional Statements - If It is an if statement or an if-else statement within an if statement If Nested If Body of If True False START END Test Expression Statement below If Body of Nested If Body of If True Nested Test Expression
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training If If-Else Switch Conditional Statements - If Syntax if (condition1) { // Executes when condition1 is true if (condition2) { // Executes when condition2 is true } } If Nested If
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training If If-Else Switch Conditional Statements - If Else It is an upgraded if statement that tests the condition and if the condition is false then ‘else’ statement is executed If-Else If-Else-If Ladder
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training If If-Else Switch Conditional Statements - If Else It tests the condition and if the condition is false then ‘else’ statement is executed If-Else If-Else-If Ladder True False START END Test Expression Statement below If Body of ElseBody of If
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training If If-Else Switch Conditional Statements - If Else If-Else If-Else-If Ladder Syntax if (condition) { //Executes this block if condition is true } else { //Executes this block if condition is false }
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training If If-Else Switch Conditional Statements - If Else If-Else If-Else-If Ladder If-else-if ladder allows the user to use many if else statement within a loop and in case one of the condition holds true the rest of the loops is bypassed True False START Statement below If-else-if Statement 1 Test Expression Test Expression Test Expression Statement 2 Statement 3 Body of Else False True True
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training If If-Else Switch Conditional Statements - If Else If-Else If-Else-If Ladder Syntax if (condition) { statement; } else if (condition) { statement; } . . else statement;
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training If If-Else Switch Conditional Statements - Switch The switch statement provides an easy way to execute conditions to different parts of the code True START Switch Condition 1 Condition n Default Condition 2 Statement 1 break; Statement 2 break; Statement n break; Default Statement True True True False False False Statement just below Switch Case
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training If If-Else Switch Conditional Statements - Switch Syntax switch (expression) { case value1: statement1; break; case value2: statement2; break; . . case valueN: statementN; break; default: statementDefault; }
Jump Statements break continue return
Jump Statements break continue return
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training break continue return Jump Statements - break The break construct is used to break out of the middle of loops After a break, all the remaining statements in the loop are skipped and the execution continues with the immediate next statement outside the loop It is used in loops (while, for, do-while) and in a switch case
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training break continue return Jump Statements - break Syntax if(condition) { break; } Remaining body of loop Statement below loopBreak? Test Expression True No Yes
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training break continue return Jump Statements – continue Continue statement is used to skip execution of statements within a loop It doesn’t terminate the loop but just skips some part of it to start the next iteration
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training break continue return Jump Statements – continue Remaining body of loop Statement below loop Continue? Test Expression True No Yes Syntax if(condition) { continue; }
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training break continue return Jump Statements – return The return statement is used to end the execution of a specific method and then return a value It sends the program control back to the method caller The data type of the returned value should always be equal to the data type of the method's declared return value Syntax if(condition) { return; }
Java Arrays 1D 2D
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training Java Arrays – 1 Dimensional 1D 2D Array is an object which contains fixed number of elements of a similar data type under same name arrayRefVar = new dataType[arraySize]; =myArray new int[5] myArray[0] myArray[1] myArray[2] myArray[3] myArray[4] =myArray[0] 10
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training 1D 2D Array is an object which contains fixed number of elements of a similar data type under same name arrayRefVar = new dataType[arraySize]; =myArray new int[5] myArray[0] myArray[1] myArray[2] myArray[3] myArray[4] =myArray[2] 10 30 =myArray[3] 40 =myArray[4] 50 =myArray[1] 20 Java Arrays – 1 Dimensional
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training 1D 2D Array is an object which contains fixed number of elements of a similar data type under same name arrayRefVar = new dataType[arraySize]; =myArray new int[5] myArray[0] myArray[1] myArray[2] myArray[3] myArray[4] 10 30 40 5020 Java Arrays – 1 Dimensional
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training 1D 2D Java Arrays – 2 Dimensional Like a 1D array, a 2D array is also a collection of data cells, all of the same type, which can be given a single name datatype[][] arrayRefVar = new dataType[row][col]; =int[][] myArray new int[2][2] myArray[0][0] myArray[0][1] myArray[1][0] myArray[1][1] =myArray[0][0] 100
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training 1D 2D Java Arrays – 2 Dimensional Like a 1D array, a 2D array is also a collection of data cells, all of the same type, which can be given a single name datatype[][] arrayRefVar = new dataType[row][col]; =int[][] myArray new int[2][2] myArray[0][0] myArray[0][1] myArray[1][0] myArray[1][1] =myArray[0][1] 200 100 =myArray[1][0] 300 =myArray[1][1] 400
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training 1D 2D Java Arrays – 2 Dimensional Like a 1D array, a 2D array is also a collection of data cells, all of the same type, which can be given a single name datatype[][] arrayRefVar = new dataType[row][col]; =int[][] myArray new int[2][2] myArray[0][0] myArray[0][1] myArray[1][0] myArray[1][1] 200100 300 400
Java Tutorial For Beginners - Step By Step | Java Basics | Java Certification Training | Edureka

Java Tutorial For Beginners - Step By Step | Java Basics | Java Certification Training | Edureka

  • 1.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training
  • 2.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training 01 IntroductionTo Java 02 JVM vs JRE vs JDK 03 Java Fundamentals 04 Objects & Classes 05 Methods & Access Modifiers 06 Flow Of Control 07 Arrays Topics For Today’s Discussion
  • 3.
  • 4.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training Introduction To Java High Level Programming Language Father of Java is James Gosling Released by Sun Microsystems in 1996 Write Once Run Anywhere (WORA) Originally called OAK Free and Open Source Software
  • 5.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training Features Of Java PortableRobustEasy Distributed Object Oriented Platform Independent MultithreadedInterpretedSecure
  • 6.
    JVM vs JREvs JDK
  • 7.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training ✓ JVM is an abstract machine that doesn’t exist physically ✓ Provides runtime environment to drive the Java Code or applications ✓ It compiles the Java code into bytecode ✓ It is platform dependent JVM vs JRE vs JDK Java Virtual Machine JVM
  • 8.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training ✓ JRE is the environment within which the JVM runs ✓ It contains a set of libraries + other files that JVM uses at runtime ✓ Also called Java RTE JRE JVM vs JRE vs JDK JVM Java Runtime Environment
  • 9.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training JDK JRE JVM vs JRE vs JDK JVM ✓ JDK is a software development environment which is used to develop Java applications and applets ✓ It contains Development Tools and JRE Java Development Kit
  • 10.
  • 11.
  • 12.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training Java Objects An real-world entity that has state and behaviour is known as an object 01State It is the data (value) of an object Behavior02 It is the functionality) of an object 03 Identity The object identity is typically implemented via a unique ID that is used internally by the JVM CHARACTERISTICS
  • 13.
  • 14.
  • 15.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training Java Classes A class is a group of objects which have common properties class <class_name>{ field; method; }
  • 16.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training Java Classes A class may contain Fields Methods Constructors Blocks Nested Class & Interface class <class_name>{ field; method; }
  • 17.
  • 18.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training Variables DataTypes Operators Variable refers to the name of reserved memory area 1 2 3 Instance Variables Static Variables Local Variables Java Fundamentals - Variables
  • 19.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training Variables DataTypes Operators DataTypes Primitive Non-Primitive Boolean Numeric Character Integral Integer FloatingPoint boolean char byte short int long float double StringArray Java Fundamentals – Data Types
  • 20.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training Variables DataTypes Operators 2 31 4 5 6 7 Arithmetic Operators Bitwise Operators Logical Operators Relational Operators Ternary Operators Assignment Operators 8 + - * ? % ^ & | && || < > <= >= == != ? : = += -= *= /= %= &= ^= |= <<= >>= >>>= ++X --X X++ X-- +X –X ! ~ << >> >>> Shift Operators Unary Operators Java Fundamentals - Operators
  • 21.
  • 22.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training Java Methods A method is a set of code that is grouped together to perform a specific operation Pre Defined or Standard Library Methods User Defined Methods A method must be written inside a class Each method has its own signature Java provides two types of methods
  • 23.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training Java User Defined Methods Method Initialization Method Invocation To use a method, you need to perform two steps:
  • 24.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training Java Methods Method Initialization Method Invocation modifier returnType nameOfMethod (Parameter List) { // method body } ✓ A method can be parameterized or non-parameterized ✓ Method definition consists of a method header and a method body ✓ You can Overload Method i.e. Provide same name to more than one method but their data type or parameter list must be different
  • 25.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training Java Methods Method Initialization Method Invocation ✓ To use a method it needs to be invoked or called ✓ A method can be called in two ways: 1. Call by Value 2. Call by Reference ✓ When a program invokes a method, the program control gets transferred to the called method methodName() methodName(parameter1, parameter2...)
  • 26.
  • 27.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training Access Modifiers Access modifiers helps to restrict the scope of a class, constructor , variable , method or data member Default Public Private Protected
  • 28.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training Access Modifiers Default Public Private Protected Same class Same Package subclass Same Package non- subclass Different package subclass Different package non- subclass Yes Yes Yes Yes Yes No Yes Yes Yes No Yes Yes No No Yes Yes No No No Yes
  • 29.
  • 30.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training My First Java Program class Demo{ public static void main(String args[]){ System.out.println("Hello Edureka!!!"); } } public static void main(String args[])
  • 31.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training public static void main String args[] My First Java Program public static void main(String args[])
  • 32.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training public static void main(String args[]) It is a keyword which identifies the class related thing It is used to define the Return Type of the Method It is the name of the method that is searched by JVM as a starting point for an application with a particular signature only It is the parameter to the main Method where the argument name could be anything It is the access modifier of the main method My First Java Program public static void main String args[] NOTE: main() in Java is the most important method as it is the entry point of any java program
  • 33.
  • 34.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training For While DoWhile It is a control structure that allows us to repeat certain operations by incrementing and evaluating a loop counter Iterative Statements – For Loop Statement Initialization Condition Increment /Decrement False True START END
  • 35.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training For While DoWhile Iterative Statements – For Loop Syntax for(initialization; condition; incr/dcr) { code block; } Statement Initialization Condition Increment /Decrement False True START END
  • 36.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training For While DoWhile Iterative Statements – While Loop It is a control structure that allows us to specify that a certain statement is to be executed repetitively until the loop condition is false Statement Condition False True START END
  • 37.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training For While DoWhile Iterative Statements – While Loop Syntax while (boolean condition) { loop statements... } Statement Condition False True START END
  • 38.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training For While DoWhile Iterative Statements – Do While Loop It is a control structure that allows code to be executed repeatedly based on a given Boolean condition and tests the condition before executing the loop body Statement Condition False True START END
  • 39.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training For While DoWhile Iterative Statements – Do While Loop Statement Condition False True START END Syntax do{ //code to be executed } while(condition);
  • 40.
  • 41.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training If If-Else Switch Conditional Statements - If It is the simplest selection statement in the Java language that checks the condition and executes the loop if condition is true If Nested If
  • 42.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training If If-Else Switch Conditional Statements - If If is the most simple decision making statement that decides whether a certain statement or block of statements will be executed or not Body of If True False START END Test Expression Statement below If If Nested If
  • 43.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training If If-Else Switch Conditional Statements - If Syntax if(condition) { //Statements to execute if condition is true } If Nested If
  • 44.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training If If-Else Switch Conditional Statements - If It is an if statement or an if-else statement within an if statement If Nested If Body of If True False START END Test Expression Statement below If Body of Nested If Body of If True Nested Test Expression
  • 45.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training If If-Else Switch Conditional Statements - If Syntax if (condition1) { // Executes when condition1 is true if (condition2) { // Executes when condition2 is true } } If Nested If
  • 46.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training If If-Else Switch Conditional Statements - If Else It is an upgraded if statement that tests the condition and if the condition is false then ‘else’ statement is executed If-Else If-Else-If Ladder
  • 47.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training If If-Else Switch Conditional Statements - If Else It tests the condition and if the condition is false then ‘else’ statement is executed If-Else If-Else-If Ladder True False START END Test Expression Statement below If Body of ElseBody of If
  • 48.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training If If-Else Switch Conditional Statements - If Else If-Else If-Else-If Ladder Syntax if (condition) { //Executes this block if condition is true } else { //Executes this block if condition is false }
  • 49.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training If If-Else Switch Conditional Statements - If Else If-Else If-Else-If Ladder If-else-if ladder allows the user to use many if else statement within a loop and in case one of the condition holds true the rest of the loops is bypassed True False START Statement below If-else-if Statement 1 Test Expression Test Expression Test Expression Statement 2 Statement 3 Body of Else False True True
  • 50.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training If If-Else Switch Conditional Statements - If Else If-Else If-Else-If Ladder Syntax if (condition) { statement; } else if (condition) { statement; } . . else statement;
  • 51.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training If If-Else Switch Conditional Statements - Switch The switch statement provides an easy way to execute conditions to different parts of the code True START Switch Condition 1 Condition n Default Condition 2 Statement 1 break; Statement 2 break; Statement n break; Default Statement True True True False False False Statement just below Switch Case
  • 52.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training If If-Else Switch Conditional Statements - Switch Syntax switch (expression) { case value1: statement1; break; case value2: statement2; break; . . case valueN: statementN; break; default: statementDefault; }
  • 53.
  • 54.
  • 55.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training break continue return Jump Statements - break The break construct is used to break out of the middle of loops After a break, all the remaining statements in the loop are skipped and the execution continues with the immediate next statement outside the loop It is used in loops (while, for, do-while) and in a switch case
  • 56.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training break continue return Jump Statements - break Syntax if(condition) { break; } Remaining body of loop Statement below loopBreak? Test Expression True No Yes
  • 57.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training break continue return Jump Statements – continue Continue statement is used to skip execution of statements within a loop It doesn’t terminate the loop but just skips some part of it to start the next iteration
  • 58.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training break continue return Jump Statements – continue Remaining body of loop Statement below loop Continue? Test Expression True No Yes Syntax if(condition) { continue; }
  • 59.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training break continue return Jump Statements – return The return statement is used to end the execution of a specific method and then return a value It sends the program control back to the method caller The data type of the returned value should always be equal to the data type of the method's declared return value Syntax if(condition) { return; }
  • 60.
  • 61.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training Java Arrays – 1 Dimensional 1D 2D Array is an object which contains fixed number of elements of a similar data type under same name arrayRefVar = new dataType[arraySize]; =myArray new int[5] myArray[0] myArray[1] myArray[2] myArray[3] myArray[4] =myArray[0] 10
  • 62.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training 1D 2D Array is an object which contains fixed number of elements of a similar data type under same name arrayRefVar = new dataType[arraySize]; =myArray new int[5] myArray[0] myArray[1] myArray[2] myArray[3] myArray[4] =myArray[2] 10 30 =myArray[3] 40 =myArray[4] 50 =myArray[1] 20 Java Arrays – 1 Dimensional
  • 63.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training 1D 2D Array is an object which contains fixed number of elements of a similar data type under same name arrayRefVar = new dataType[arraySize]; =myArray new int[5] myArray[0] myArray[1] myArray[2] myArray[3] myArray[4] 10 30 40 5020 Java Arrays – 1 Dimensional
  • 64.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training 1D 2D Java Arrays – 2 Dimensional Like a 1D array, a 2D array is also a collection of data cells, all of the same type, which can be given a single name datatype[][] arrayRefVar = new dataType[row][col]; =int[][] myArray new int[2][2] myArray[0][0] myArray[0][1] myArray[1][0] myArray[1][1] =myArray[0][0] 100
  • 65.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training 1D 2D Java Arrays – 2 Dimensional Like a 1D array, a 2D array is also a collection of data cells, all of the same type, which can be given a single name datatype[][] arrayRefVar = new dataType[row][col]; =int[][] myArray new int[2][2] myArray[0][0] myArray[0][1] myArray[1][0] myArray[1][1] =myArray[0][1] 200 100 =myArray[1][0] 300 =myArray[1][1] 400
  • 66.
    JAVA CERTIFICATION TRAININGwww.edureka.co/java-j2ee-soa-training 1D 2D Java Arrays – 2 Dimensional Like a 1D array, a 2D array is also a collection of data cells, all of the same type, which can be given a single name datatype[][] arrayRefVar = new dataType[row][col]; =int[][] myArray new int[2][2] myArray[0][0] myArray[0][1] myArray[1][0] myArray[1][1] 200100 300 400