This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | Introduction to Java | |
| In this tutorial, we will learn Introduction to Java. Java is an object-oriented programming language. Java language was developed by James Gosling at Sun Microsystems Inc. In starting they were thinking to name this language Oak, But this name was already registered by another company so they named it Java. Java is a breed of coffee. So that is why coffee mug is the logo of Java. Sun Microsystems was developed in the year 1982 by four persons. From these four persons, One person was Vinod Khosla. He was an Indian and passed out from IIT Delhi. Java was originated at Sun Microsystem in 1991. | |
| Sun Microsystems Company developed software for Appliances. But there was a problem they had to developed software for every platform even they were working same so that is by they invent Java language to overcome this problem. On January 27, 2010, Sun Microsystems was acquired by Oracle Corporation for the US $ 7.4 billion | |
| Java is Everywhere: | |
| It is a slogan by the java and it is true because java r | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | Setup Environment for Java | |
| In this tutorial, we will start with Java Language. To start with java, First, we have to install java in our machine and after installing java we have to set the path of java in our machine. That path will help us to run java programs in CMD. There are some commands which we use to run the program in CMD. So, to install java JDK(Java Development Kit). We have this link from where you can download Java JDK. If you want to download just click on this link. Click here to Download | |
| When you will complete this installation you will get two folders on that memory location, which you selected on the time of installation. By default its //C:Program Files/Java | |
| Java Development Kit | |
| Java Run-Time Environment | |
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | First Program in Java | |
| We will not waste our time we will directly move towards our Hello World first program in java. After writing our first program we will discuss the various things of our program why we are using them in our code what impact they are making in our code. | |
| Before starting, if you have a background in c++ or any other Object Oriented Language then that experience will help you in this series. But don't worry Java is not that much though in starting things may be confusing for you but with the time you find everything very easy. | |
| Please keep it in your mind that, we can not write any Method or variable outside of class, It means the main function will be also part of any class. | |
| Java Code | |
| class FirstProgram | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | Operators in Java | |
| In this tutorial, we will learn about Operators in Java. Operators are special symbols that we use to perform special operations like the addition of two numbers. | |
| Java provides us with a wide range of operators which help us to perform special operations. In Java, all the operators are divided into different categories | |
| All the operators are categorized according to their functionality like operators which perform mathematical operations like +, -, /, * that is in a different category and which perform relational operations are in different category like > or < operators | |
| Types of Operators: - | |
| Unary Operator | |
| Arithmetic Operator | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | Keywords in Java | |
| In this tutorial, we will learn about Keywords in Java. Java provides a wide range of keywords to us. Every keyword has some special meaning in Java. We can not use any keyword as class name or as a variable name. | |
| All keywords have some predefined meaning which Java compiler knows very well for example if you are using " while " keyword then compiler know very well that we are going to define a loop. Like other programming languages, Java has some common keywords like if, for. But it also has some special keywords like byte, implements. | |
| It's important to note we can not use any keyword as the name of an identifier (as a class name, variable name or method name.) | |
| Keyword List in Java: - | |
| abstract: - We use abstract keyword with the class to make a class abstract. We can not create an instance of abstract class | |
| boolean: - We use boolean keyword with a variable to define a variable of the boolean data type. boolean is a special kind of data type in Java and boolean variable can hold only two va | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | Keywords in Java | |
| In this tutorial, we will learn about Keywords in Java. Java provides a wide range of keywords to us. Every keyword has some special meaning in Java. We can not use any keyword as class name or as a variable name. | |
| All keywords have some predefined meaning which Java compiler knows very well for example if you are using " while " keyword then compiler know very well that we are going to define a loop. Like other programming languages, Java has some common keywords like if, for. But it also has some special keywords like byte, implements. | |
| It's important to note we can not use any keyword as the name of an identifier (as a class name, variable name or method name.) | |
| Keyword List in Java: - | |
| abstract: - We use abstract keyword with the class to make a class abstract. We can not create an instance of abstract class | |
| boolean: - We use boolean keyword with a variable to define a variable of the boolean data type. boolean is a special kind of data type in Java and boolean variable can hold only two va | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | Scanner class in Java | |
| In this tutorial, we will learn about Scanner Class in Java. Scanner class in Java is used to get input from users as we use scanf() in C language. Scanner class is a predefined class in java which is present in java.util package. It means we have to import this package to use Scanner class in Program. Here we will learn how to use Scanner class and different methods of Scanner class. | |
| Here I would like to start directly with an example which would so helpful to you to understand Scanner class. | |
| // Import the Scanner class | |
| import java.util.Scanner; | |
| class ScannerExample { | |
| public static void main(String[] args) { | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | Comments in Java | |
| In this tutorial, we will learn about Comments in Java. Comments are not used to perform any function in the program but they are really useful for developers. Developers can write comments with variables and Methods to remember their working (purpose) in the program. One important thing to mention comments doesn’t put any impact on the execution of program because compiler simply ignores them | |
| Types of Comments: | |
| Single Line comments | |
| Multi-Line comments | |
| Single-Line Comments: | |
| Single Line comments are used to add single line comment with a variable or any Method. Double slash “//’ is used to add Single-Line comments. | |
| public class Example{ | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | Arrays in Java | |
| In this tutorial, we will learn about Arrays in Java. Till now we learned about variables. We know in a variable we can store a value, for example, int num=10; Here num is variable of int type in which we can store an integer value. but suppose you want to store 100 values. It means you should have 100 variable. It will so though to create and manage 100 variables. So to overcome this kind of problem Java has a concept called Arrays. | |
| In an Array, we can store multiple values using a single identifier. In an Array, values get store according to the index numbers. Let’s check syntax to define and initialize an array in Java. | |
| Syntax to define Array in Java: | |
| int marks[5]={20,25,24,30,15}; | |
| Index system of Array: | |
| We discussed earlier how in array values stored on the index. In the following figure, you can see how values get stored on different index numbers. Index number always starts from 0. | |
| Access Array Element: | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | Branching Statements in Java | |
| In this tutorial, we will learn about Branching Statements in Java. Branching Statements helps us to set a flow of program according to our requirements. Suppose you want to execute a piece of code only in case of a certain situation. Then in this kind of situations, you can use branching statements to control the flow of the program. Java provides us with a variety of branching statements. you can use any according to your requirements. | |
| List of Branching Statements: | |
| if statement | |
| if-else statement | |
| else-if statement | |
| switch statement | |
| if statement: – we use if statement in case we want to run some piece of code only if a certain condition is true. Check out the following syntax to define if statement in Java. | 
OlderNewer