 Hello everyone, welcome back. So, today's first session would be like easy one, it's Java for Android. Most of you would be aware of Java, it lies a refreshment for you. So, let's go on for Java. What all contents I would be covering in this session? The first one would be introduction to Java, development environment, implementing a Java program, data types, variables, operators. Then these four points would be easy one. Then we are going to some advanced topic like arrays, control systems, what are static variables, methods, class, summary and references. Basically what is Java? The most common definition people give about Java is a complete platform for object oriented programming. Java is a purely object oriented. It is portable, robust, secure, etc. It is portable in the sense that you can create a Java program in one machine and run it in any other machine like Ubuntu, Magintosh, etc. It contains extensive libraries. It means there are lot of classes and method in bit classes. Java has around more than 2500 classes, in bit classes. Java is also used to create web application and desktop application and nowadays mobile applications also. We take an example of web applications like you have registered for this workshop in a Java application only. NMICT is based on Java only and the government of India has launched the Passport Seva Kendal which is also done in Java. Some of the good examples are also made in desktop application like our own proximity. It is also done in Java and clicker quiz which we will be conducting in some time. It is also done in Java. So, you can see that how it is robust and secure. GRE. What is GRE? It is a Java runtime environment. What do we require to run a Java program? We would require a GRE which provides an application programming interface. Then we come to JDK. For running this, what we require? We require a software development in Java that JDK provides us. The JDK is used for compiling as well as running the programs. Now, I want to talk about JVM. What is a Java virtual machine? There is one diagram would come just considered on JVM. Don't concentrate on whole diagram. Here, I have a class named hello.java. This is a file I have created and the hello.java is compiled through a javasi compiler. If there are no errors, it would be compiled and then hello.class would be created. It is a byte code. Now, the role comes of JVM. The JVM translates the byte code into something that the platform understands. Means, you want to make and windows or any other hardware. So, it is like a bridge between the byte code and the operating system. A Java virtual machine is a virtual machine that can execute Java byte code. It also handles memory management. Next is integrated development environment, IDE. In market, there are various IDE used like NetBeans, Eclipse, etc. We would be using Eclipse IDE because in the further sessions of Android, we would be using it. The main benefits of using Eclipse IDE are debugging is included, auto completion is possible. Suppose we have forgotten some variable name or member function, then automatically it we can type it. Another most important advantage of Eclipse IDE is we can view the files errors as well as console and source code at the same place. Currently, we would be using Eclipse 3.7 in D.O. Then comes the object-oriented programming. What is encapsulation? The simple and basic example is the wrapping of data and method into a single unit. This means that data we have in a class, it is not accessible to the outside world. So, that the class, the variables as well as the member function are secured inside it. Next comes the inheritance. Objects of one class acquires the properties of another class. Just we take an example. Suppose we would have some characteristics of our parents. It means that we are inheriting some of the qualities of our parents to ourselves. In the same way, in the same type, the classes are also like that. We can create a new class and acquire the properties of any other class. So, the new class would have its own property as well as the derived property. So, inheritance, this is known as inheritance. The main advantage of inheritance is code reusability. Then comes the polyformism. It is the ability to take more than one form. Here I have made an example like 2 plus 2 equal to 4. And in another line, I have given akash plus and or equal to akash and what does this mean? This means that the plus operator I have used for both the numeric as well as string data types. The database I will be covering, the data types I will be covering the next slide. So, just for the time being, assume that this plus I used for numeric as well as the string data type. So, this is the polyform ability to take more than one form. With the help of plus variable, we can add the number as well as concave two strings. Now, I would talk about the steps for a simple Java program. The first step would be writing a program that is hello dot java. Then we will compile the program. If there are any errors, it would not be compiled. On compilation, if the program is error free, then it will be compiled and hello dot class would be created. And finally, we would execute the program. So, I am going to demonstrate the program through command line. Currently, I am using ubuntu. So, like if somebody is using windows, then you have to type in notepad or wordpad. So, I am creating a simple Java program. I am using gadd editor. So, the editor has opened public static void main. So, I increase the font size. So, it would be visible. Here, I created a class name hello. Now, I am displaying a simple message. The aim is to show how the Java first program is created and compiled and run. This is optional if you are having command line arguments, then you can give it. So, I am compiling it. I am compiling using javac compiler. The command is javac hello dot java. So, we are not having any error. So, a class file has been created. Suppose, I am purposely doing some error. So, what would the output? Suppose, I am removing semicolon and saving it and closing it. Now, I again compile it with javac hello dot java. Here, I get an error. So, this means that if there is some error, then we cannot create a class file. Again, I put the semicolon, save it, close it and compile it using javac hello dot java. Now, successfully we have compiled. Now, I run the program using java hello. So, we get the output welcome to android workshop. So, these are the steps for implementing a simple Java program. Now, we come to data types. The data types which are seeing in the left hand side table are the primitive data types. The size in bit is given here. We can see that Boolean has one bit and the largest has a 64 bit that is of double int contains 32 bit. Why are data types required? Because we want to store the value, the range. The data types specify the size and type of the values that can be stored. Then comes the variables. If you have the data type, then you should have the variables also. So, a variable is an identifier that denotes a storage location used to store a data type. I have given an example int count. Int is a data type and count is a variable and I am declaring it. In the second one, I am assigning or giving the value to the variable count equal to 1. Now, the value 1 is in count. Now comes the operators. First is arithmetic operators. These arithmetic operators we would be using in our school days also. The same is here only. I have given the example like a plus b will give 30. The initial value of a is 10 and b equal to 20. Next comes the relational operators like we want to compare two values, two strings or then relational operators are used. One example is that a not equal to b. The result would be true because a is 10 and b is 20. So, both are not equal. So, it will give a value. So, it is true. Assignment operator. In the previous slide, I assigned one value to the variable. So, in that I have used assignment operator equal to. The example is c plus equal to a is same as c equal to c plus a. Means we are adding c and storing the resultant value in the same variable c. Then we have increment as well as decrement operators double plus and double minus. b minus minus gives 19. The value is 20 b equal to 20 and then we decrement by 1 that gives 19. Suppose we increment, we make increment of a plus plus then we will get a equal to 11 array. What is an array? An array is a group of related data types, items that share a common name. Here we can see an example. These are the values, array values 10, 25, 34 and 46. We should know that like arrays are stored in indexes starting from 0, 0, 1, 2, 3. These all numbers like you should have of only one that particular data type. You cannot have int, then float, then string. You should contain the item of only one data type. The example is how to declare an array. This is the syntax. This is how we create an array, int square bracket. My array is name given by the user equal to new and int and this is the size 4. Means these four boxes would be created in the memory. This is how we initialize the array. We are putting the value into the array 10, 25, 34, 46. We would be seeing examples after some times. Control statements. What are control statements? Like there may be a situation when we need to execute a block of code several times. It may happen that we want to add some numbers like 1 to 10. What we will do? We will use loops or a more easier part would be like we want to type a message 100 times. So, we would not be using, we would not be typing that message for 100 times. We would be losing any of these three loops. So, now I am going to show the practical implementation of loops. I have already written the program to save the time and also I will explain the code. First of all let me take for loop. It is one of the easiest loops. This is a class using for loop. Inside I declared a variable int x equal to 1 and this is the for loop. The syntax is first we initialize it. Then you should know till which number we are going to end it and next is increment part. How much number we are going to increment it? Here I am incrementing it by 1. This particular line I am displaying the value of x means whatever the value of x would be printed at each time. Each time the loop iterates and in the next line I am just in a new, fitting a new line character. So, I am running the program. Here it is. Below down you will see the in the console the value of x by using loop is 1. It would be till 9 because 10 is not included. If we put equal to mark 10 would be included. Then next we will see using while loop. This is the syntax of while loop. While we would have an Boolean expression true or false. If it is true, it will go inside false. It will not go into the loop. Here the output would be same as the previous program. I have declared x equal to 1. x less than 10 means it will print till 9. The same statement I have written here. Statement.system.out.printl value of x by using loop is x means every time it goes inside the loop the value of x would be displayed. And I am incrementing x here. Then I am feeding a new line character. Now I am running the this code run as Java application. This is the output value of x by using while loop is 1 and we are getting till 9. The third is do while loop. The main benefit of using do while is like at least once you will be inside the loop. Loop means the checking of the statement is done at the end of the statement. Means x is less than 10 means the loop at least once would come inside execute this code. Then it will check whether it is true or false. But at that time already the first line of code would be executed. So, do while loop executes at least once. Here also I am declaring int x equal to 1. Then I am displaying the value of x and then I am incrementing value of x by x plus plus and then feeding the new line character. Let me run the program run as Java application. So, I am getting the output as value of x by using do while loop is 1 till 9. Suppose I change the value of x to 11. So, what I will get? You will at least once the loop would go inside. Let us see the output means value of x by using do while is 11. The condition is false. Then also the execution takes place because this is the checking of the checking is done at the end of the loop. Here it is. Next comes the static variable. What are static variables? Static variables are the shared across all the objects of the class. Like here is a figure. I have declared two objects. Now, just do not concentrate on objects. It would be covered in the further sessions. Assume that these are two variables and sharing one common variable. There is A and B and it shares shared resources like one. Here is a code. I have created a class test and this is the static variable static int x underscore equal to 1. So, the output would be like test A object creation, test B object creation. Then I am printing the value of x through the object P. Then I get 1 because it is the initial value of 1. Then I change the value of A dot x equal to 5. Then again I am changing the value of x underscore and again I am printing through the object B dot x. Means I will get the value 5. It means that any one resource changes the value of x. Others can access this. It has one common value. The real example would be initializing the value of pi. At the beginning of the program initialize the value of pi. Then any other object can access it. Then comes the method. A simple Java method requires a minimum of three items. Before that what is the definition of method? It is a collection of statement grouped together to perform an operation. We would be looking a program of this like adding two numbers visibility. It means that method is either public, private or protected. Public means anybody can access it whose all has access to the class can access it. Private means only those objects can access it. Each other member function or the variables can access it. Return time. Return time means void or int or double. If during the function it executes a goal and returns back to some value then these return times are used. Void is used just for displaying some message. Int or double after some calculation it can return values. Name whatever you want to call the method but it should be a valid name and not any of the keywords. Here is the program explaining the methods. Here I am adding two numbers through method. This is the class. I am declaring two numbers first number as well as second number and initializing to five and two. Then this is the important sentence. Here I am declaring a method named sum and as an argument I am passing two integers. This is public means it can be accessible to the class. Then I am declaring a integer result. Result equal to number 1 plus number 2. What all argument comes here would be replaced here and it returns result. Result means it is a data type int means after calculation this method would return an integer value here. Sum first number comma second number. These two number would be passed here and this method would return one sum result. Then this result I am displaying at the end. The addition of first number and second number is result. Let me run the program. Here you can see the addition of five and two is seven. So, just have a look at the method. Main part is this arguments and return type and it should return summary. What all topics we have covered in this half and over? What is Java? Till now you would be cleared. What is Java? The object oriented concepts. A simple Java program. What are data types? Variables, operators, arrays, control statements, static variables, methods and classes. Thank you.