Arrays
- Using Arrays, multiple values of same data type can be stored into a single variable.
- Arrays can be categorized as below:

- Single Dimensional Array
- Example: int[] a = new int[3];
- Demonstrate Declaring, Creating, Assigning and Accessing the single dimensional Array – Demonstrate here
- View the diagrammatic representation of single dimensional array here
- Shortcut representation of single dimensional array
- ‘length’ predefined variable of Arrays
- Using for loop with single dimensional arrays
- Using for-each loop with single dimensional arrays
- ArrayIndexOutOfBoundsException
- Two Dimensional Array
- Example: int[][] a = new int[2][3];
- Two dimensional Array is nothing but array of single dimensional arrays.
- View the diagrammatic representation of two dimensional array here
- Demonstrate Declaring, Creating, Initializing and Accessing the two dimensional Array
- Shortcut representation of two dimensional array
- ‘length’ predefined variable of Arrays
- Using for loop with two dimensional arrays
- Others topics on Arrays
- Arrays and different Data type declarations
- Disadvantages of Arrays
- Fixed in Size
- Solution: Collections Framework – ArrayList
- Cannot store different types of literals into a single variable
- Solution: Object Arrays
String
String is not a data type, instead it is a predefined class in Java Class Library
- Google “Java 11 API” and find the String class in the Java Class Library
- Actual Representation of String – String s = new String(“Sample Text”);
- Shortcut Representation of String – String s = “Sample Text”;
- Concatenate two strings
- using ‘+’ operator
- Predefined methods of String class – Out of all the predefined methods of Strings, the below are the methods which are useful as part of Selenium Automation:
- Using equals() method to compare two strings
- Using length() method to find the length of String literal text
- Using substring() method to retrieve the portion from the actual String text
- Using trim() to remove the spaces before and after the string text
- Using indexOf() to check whether the provided text is in the provided paragraph.
- Returns -1 in case the provided text is not available
- Using split() method to split the text into different parts based on the provided text, symbol or space.
Wrapper Classes and Primitive Data types
In order to use primitive data types as Objects, we have to use Wrapper Classes which help us in converting the primitive data types into objects.
- The below are the different primitive data types:

- For, all the above data types, there are corresponding Wrapper Classes as shown below:

- Demonstrate a program which uses Wrapper Classes for converting the primitive data types into Objects and Objects into primitive data types
- String and using Wrapper classes for conversion to appropriate data type
Exception Handling
Exception is nothing but an error which is occurred during runtime i.e. during program execution
- If an exception has occurred during program execution at any step, the steps which are after the exception wont be executed
try catch blocks
- We can handle the exceptions using the try catch blocks
- Handling the exceptions is known as Exception Handling
- Syntax: View here
- Explain the flow of try catch block – view here
- Demonstrate a program having code to handle the exception using try catch blocks
- In the above Syntax image, ‘Exception’ is the Class name and ‘e’ is the object reference which can catch the exception (i.e. object) thrown from try block
Exceptions Hierarchy

- Demonstrate ArithmeticException and handle it using ‘ArithmeticException’ class in catch block
- Demonstrate ArrayIndexOutOfBoundsException and handle it using ‘ArrayIndexOutOfBoundsException’ class in catch block
- Exception class is the parent class of all the Exception Classes like ArithmeticException and ArrayIndexOutOfBoundsException classes and can handle them
- Throwable class is the grant parent class of all the Exception Classes like ArithmeticException and ArrayIndexOutOfBoundsException classes and can handle them
Exception Types
- Exceptions can be categorized as below:

- Unchecked exceptions are the exceptions that are not checked by compiler and will occur only during execution
- Checked Exceptions are the exceptions that are checked by the compiler
- Handling Checked Exceptions using try .. catch block
- Ignoring Checked Exceptions using throws keyword
By,
Arun Motoori