A Guide to JAVA
Introduction to JAVA What is JAVA? JAVA is an object-oriented programming language. It was developed at Sun Microsystems and was led by James Gosling. It has the slogan Write Once, Run Anywhere, which means that programs written in JAVA can run on any platform. Features of JAVA Object-oriented Programming Language Using an object-oriented programming language increases code reusability and improves maintainability. Platform Independence Programs written in JAVA can run on any platform. Multi-threaded Support Using multi-threads allows multiple tasks to be processed simultaneously, improving program performance. Dynamic Loading Support Using dynamic loading allows classes required during program execution to be loaded dynamically. Exception Handling Support Using exception handling allows exceptions that occur during program execution to be handled. Setting up the JAVA Development Environment Install JDK (Java Development Kit) Installing JDK allows you to set up the environment to develop JAVA programs. Install Code Editor Installing a code editor allows you to write JAVA code. Popular code editors: IntelliJ IDEA, Eclipse Executing JAVA Compile Compiling JAVA source code generates bytecode. Compile command: javac HelloWorld.java Run Running bytecode executes the JAVA program. Run command: java HelloWorld JAVA Basic Syntax Operators and Iterations Operators JAVA provides various operators. Popular operators: +, -, *, /, % Operators allow you to perform specific operations. 1 2 3 4 int a = 10; int b = 20; int c = a + b; System.out.println(c); Iterations JAVA provides various iterations. Popular iterations: for, while, do-while Iterations allow you to repeatedly perform specific tasks. 1 2 3 for (int i = 0; i < 10; i++) { System.out.println(i); } Methods and Fields Methods ...